2 Replies Latest reply on May 6, 2016 12:05 PM by madeleinel22391508

    Automatically populate a drop-down box using another drop-down box selection

    madeleinel22391508

      New to java/preparing forms so I apologize in advance.

       

      I currently have a drop down box 1 (Occupation) with three options: "enter your own description/blank", retired, homemaker. When someone chooses either retired or homemaker, I would like another drop box 2 (Employer) to automatically populate to "N/A". The employer drop box only has two options: "enter your own/blank", N/A.

       

      So far, I have been able to have the box populate however, only when the person clicks into the box (as if they were going to enter their own text.) Only then will it populate the drop down box "employer." I would like it to auto populate once the person has chosen retired, blank or homemaker without having to enter the box (just using the arrow at the size of the drop-down box.)

       

      I currently have a key stroke in place that resets the employer box when a person chooses the blank option/enter your own option. I then have a JavaScript (just for homemaker currently) that only works if you click into the box.The keystroke is working how I would like the other options to work as well. If the client settles on the blank, the employer option automatically updates to blank without having to click into the box. Any help (including general tips to making my code cleaner) is much appreciated!

       

      Current Keystroke script:

      if( event.willCommit ) {

         if(event.value == " ") this.resetForm(["Employer"]); else SetFieldValues(event.value);

      }

       

      Current mouse up, run JavaScript:

       

      var v=this.getField("Occupation").value

       

      if(v == "Homemaker")

      1. this.getField("Employer").value = "N/A"

      I think that I should possibly be using event.willCommit in my formula but I am unsure of how to include it.

       

      Thanks!