5 Replies Latest reply on Oct 29, 2014 4:41 PM by raemay

    Adding Dropdown Values according selected value in another dropdown.

    thesherburnes

      Hi All,

      I have been searching for a solution to what I am trying to do in these discussions and some of them are close, but the code I have been trying to add/manipulate just doesnt seem to work quite right, so hopefully someone can help me.  I am new to Javascript and have been trying to learn slowly, but i assume this is an easy solution for some.  I have two dropdown menus, the first one the user is to select a value (lets say "1234"), the second dropdown is to display items that i want related to that value (lets say "1", "2", "3", "4")  This is necessary for my form so users dont have to search for related values according to what they chose.

       

      I have found a script that uses the setitem method, however the items are not keeping their selection.  What i mean by that is that it will set the items correctly in the dropdown, but when i go to select, it keeps the first value.

       

      I currently have:

       

      if(this.getField("M-Item1).value== 'M1400') {

      var 1 = this.getField("Dropdown3");

      1.setItems(["M1400 List"], ["ITEM 1",""],["ITEM 2",""],["ITEM 3",''],["ITEM 4,""],[" "]]);

      1.setreadonly = false;

      1.editable = true;

      }

      else if (this.getField("M-Item1).value== 'M1342') {

      var 1 = this.getField("Dropdown3");

      1.setItems(["M1342 List"], ["ITEM 5",""],["ITEM 6",""],["ITEM 7",''],["ITEM 8,""],[" "]]);

      1.setreadonly = false;

      1.editable = true;

      }

       

      This gives me ITEM 5-8 if i select M1342 in a dropdown, and ITEM 1-4 if M1400 is selected.  If i select an item in the dropdown, lets say 3, the value defaults to M1400 List.

       

      Any help on this would be greatly appreciated, thanks!!!!!