Need to display the select box values based on another select box

Srvs
Kilo Guru

Hi

please help me to display the select box values based on another select box   in a catalog item form.

for example i need to display the "states" based on "country" in catalog item form... please help me..

Regards

venky

8 REPLIES 8

Srvs
Kilo Guru

Hi,


by using above i created two dropdowns.


g_form.clearOptions('B'); is not working in first time,



i am getting all the fields in 2nd dropdown at first time. after changing the value in 1st dropddown it is working.



pleas help me to resolve.



Regards


venky


Hi,



You can have a default value as "None" for the first Select Box and you can hide the Second Select Box when First one is None using Catalog UI Policy. Post which if the User selects any value from the first Select Box you can display the corresponding values in Second Variable based on the script as Harish Provided above.



Hope this helps.Mark the answer as correct/helpful based on impact.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hi Venkatesh,



If i am not wrong you had same requirement on the below thread.



display dropdown field based on another, g_form.clearOptions('B'); is not working



Let me know if you have any further question.



Thanks,


Harshvardhan




Please like, mark as correct/helpful if it is right.


Hi Venkatesh,



Can you try like below.Below script will work in onload well and it will set the first time



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


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


g_form.clearOptions('city');


var getCountry1 = g_form.getValue('country'); // country is variable name


  alert(getCountry1);


if(getCountry1=='India')


  {


  g_form.addOption('city','Bangalore','Bangalore'); // city is variable name, bangalore is the choices in your select box


  g_form.addOption('city','Chennai',' Chennai');


  }


    //Type appropriate comment here, and begin script below


    else if(getCountry1=='Aus')


  {


  g_form.addOption('city','Brisbane','Brisbane');


  }


          return;


    }


  g_form.clearOptions('city');


var getCountry = g_form.getValue('country'); // country is variable name


  alert(getCountry);


if(getCountry=='India')


  {


  g_form.addOption('city','Bangalore','Bangalore'); // city is variable name, bangalore is the choices in your select box


  g_form.addOption('city','Chennai',' Chennai');


  }


    //Type appropriate comment here, and begin script below


    else if(getCountry=='Aus')


  {


  g_form.addOption('city','Brisbane','Brisbane');


  }


}



Thanks