0 Replies Latest reply on Apr 12, 2016 11:07 AM by maddyl31788266

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

    maddyl31788266

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

       

      I currently have a drop down box (Occupation) with three options: "enter your own description/blank", retired, homemaker.  When someone chooses either retired or homemaker, I would like another drop box (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 on the box (as if they were going to enter there 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.) 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")

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