Hi Community..i need to populate the drop down list based on the another dropdown value.Please help me out.

Nana5
Mega Guru

Hi Community..i need to populate the drop down list based on the another dropdown   value.Please help me out.

example: there is drop down called state, if user will select the state(eg:karnataka), then in below drop down i need to display all the district of that state.Please help me in this.Thanjks

1 ACCEPTED SOLUTION

Nana5
Mega Guru

Hi All


I have done using client script


function onChange(control, oldValue, newValue, isLoading) {


  if (isLoading || newValue == '') {


  return;


  }


  var u_ent = g_form.getValue('u_entity');


  alert(u_ent);



  if(newValue == 'Austria'){



  var dVals = '20,21,22,24,60,70,90';


  var dOpts = dVals.split(',');


  var myIndex = 1;



  //housekeeping, clear values in case this is used onchange


  g_form.clearValue('u_tax_code_sub');


  g_form.clearOptions('u_tax_code_sub');



  //Add the standard none option


  g_form.addOption('u_tax_code_sub', '-- None --', '-- None --', 1);



  for (i = 0; i <   dOpts.length; i++) {


  myIndex++;


  g_form.addOption('u_tax_code_sub',   dOpts[i],   dOpts[i], myIndex);



  }


}


if(newValue == 'Belgium Sales Company'||newValue == 'Belgium Plant'){



  var u_code = 'V0,V1,V2,V3,V4,V5,V6,VA,VB,VC,VD,VE,VF';


  var u_split = u_code.split(',');


  var myIndex1 = 1;



  //housekeeping, clear values in case this is used onchange


  g_form.clearValue('u_tax_code_sub');


  g_form.clearOptions('u_tax_code_sub');



  //Add the standard none option


  g_form.addOption('u_tax_code_sub', '-- None --', '-- None --', 1);



  for (i = 0; i <   u_split.length; i++) {


  myIndex1++;


  g_form.addOption('u_tax_code_sub',   u_split[i],   u_split[i], myIndex1);



  }


}


if(newValue == 'Sweden Sales Company'){



  var u_code1 = '21,22,23,60,70,80,90';


  var u_split1 = u_code1.split(',');


  var myIndex2 = 1;



  //housekeeping, clear values in case this is used onchange


  g_form.clearValue('u_tax_code_sub');


  g_form.clearOptions('u_tax_code_sub');



  //Add the standard none option


  g_form.addOption('u_tax_code_sub', '-- None --', '-- None --', 1);



  for (i = 0; i <   u_split1.length; i++) {


  myIndex1++;


  g_form.addOption('u_tax_code_sub',   u_split1[i],   u_split1[i], myIndex2);



  }


}


if(newValue == 'Spain'){



  var u_code2 = 'R0,R7';


  var u_split2 = u_code1.split(',');


  var myIndex3 = 1;



  //housekeeping, clear values in case this is used onchange


  g_form.clearValue('u_tax_code_sub');


  g_form.clearOptions('u_tax_code_sub');



  //Add the standard none option


  g_form.addOption('u_tax_code_sub', '-- None --', '-- None --', 1);



  for (i = 0; i <   u_split2.length; i++) {


  myIndex1++;


  g_form.addOption('u_tax_code_sub',   u_split2[i],   u_split2[i], myIndex3);



  }


}







}


View solution in original post

10 REPLIES 10

tanumoy
Tera Guru

You can add the 1st field as dependent of the 2nd field. And in the choice list of 2nd field you can provide the 1st field choice value as dependent value.



In incident form, there is a OOB example for category and sub category:



Capture.JPG


Hi


Thanks for the response. But for each selection dependent drop-down value will change.  


Do you mean that in the 2nd field same choice may be there for different 1st field choice?


yes..best on the 1st choice selection need to popup set of value for 2nd choice.