2 Replies Latest reply on Feb 15, 2016 7:15 PM by triplejs15

    Document JS Function That Compares DD Value and Sets Textfield Value

    triplejs15

      Ok so here’s where I’m at, this is my first attempt and I've been searching/googling for some time now. Any help would be appreciated.

       

      1. Document function named UOM with two parameters, name of drop down and name of a textfield
      2. I would like the function to get the selected value from the drop down after selection, name of drop down Serv_Type_dd1
      3. Then compare the value to a string example "Attendant"
      4. If drop down value is equal to "attendant" I set the text field Value to "Hours", textfield name is Amnt_1_1
      5. Here's how I'm calling the function: UOM([“Serv_Type_dd1”,”Amnt_1_1”]) within the "On Blur" action of the Serv_Type_dd1.
      6. I have to do this comparison for 17 drop down boxes containing 25 options each options have a different value in the text box

       

       

       

      function UOM(ddvalue,textvalue)

      {

            var source = this.getField(ddvalue).value;

       

            if(source.value=="Attendant")

      {this.getField(textvalue).value = "Hours"}

      Else if {this.getField(textvalue).value = 'Null'}

      }

        • 1. Re: Document JS Function That Compares DD Value and Sets Textfield Value
          gkaiseril MVP & Adobe Community Professional

          Have you checked the JavaScript console for errors?

           

          Did you get any pop-up errors when entering your code?

           

          In the "if" statement the alternative is "else" not "Else". Capitalization is important in JavaScript.

           

          I also would use the value of the fields as parameters to the function and have the function return a value that would be used to set the value of the field.

          • 2. Re: Document JS Function That Compares DD Value and Sets Textfield Value
            triplejs15 Level 1

            I fixed the errors and got the following to work, but I have to pass the cmb box string in and return a string then set the value of the text box, I would like to be able to pass the combobox name in, the textbox name in as string then let the function set the value of the textbox based on the value selected in the combobox.

             

             

             

            function UOM(ddvalue)
            {
            retval  = "";
            var source = ddvalue;
            //app.alert(source,3);

            //if (source=="Physical Therapy")    { retval = "Visit(s)"; }
            //else
            if (source=="Other-Specified in Details")    { retval = "**Specify**"; }
            else if (source=="Intermittent Nursing (LPN)")    { retval = "Visit/or Hours"; }
            else if (source=="Nutrition or Feeding")    { retval = "Case(s)"; }
            else if (source=="Adult Companion Care")    { retval = "Hour(s)"; }
            else if (source=="Underpads")    { retval = "Package(s)"; }
            else if (source=="Transportation-Add On")    { retval = "Trip(s)"; }
            else if (source=="Medication Administration")    { retval = "Visit(s)"; }
            else { retval  = ""; }
            return retval;
            }