Client script to show specific values on catalog item

Souvick A
Tera Contributor

Hello All,

I have a requirement as below:

Variable category - option A and B

Variable sub category - options S1,S2,S3,S4

when option A selected , option S1 and S2 will be visible and on option B - option S3 and S4 will be visible.

Both these variables are select box type and options are choices configured.

Please help with the on change client script.

 

Regards

Souvick

1 ACCEPTED SOLUTION

Try this

 

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
// Selective options on category
var cat = g_form.getValue('category');
alert('Value of:'+cat);
if (cat == 'A'){
  g_form.clearOptions('sub_category');
g_form.addOption('sub_category', 'S1', 'S1');
g_form.addOption('sub_category', 'S2', 'S2');
}
 else if (cat == 'B'){
  g_form.clearOptions('sub_category');
g_form.addOption('sub_category', 'S3', 'S3');
g_form.addOption('sub_category', 'S3', 'S3');
}
 }

 

-Anurag

View solution in original post

6 REPLIES 6

Try this

 

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
// Selective options on category
var cat = g_form.getValue('category');
alert('Value of:'+cat);
if (cat == 'A'){
  g_form.clearOptions('sub_category');
g_form.addOption('sub_category', 'S1', 'S1');
g_form.addOption('sub_category', 'S2', 'S2');
}
 else if (cat == 'B'){
  g_form.clearOptions('sub_category');
g_form.addOption('sub_category', 'S3', 'S3');
g_form.addOption('sub_category', 'S3', 'S3');
}
 }

 

-Anurag

Thank you Anurag for your input.

 

Regards
Souvick