How to apply onchange catalog client Script to display the select box values based on another select box

Priya10
Kilo Contributor

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

For example I want to write catalog client script of type onchange because when I select Neurologist in select box so available doctors should be those only whose specialization is Neurologist. 

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi Priya,

You would require onchange client script on the select item variable; sample script below, just adjust or tweat as per your values:

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading) {
      return;
   }

g_form.clearOptions('request_type');

if(newValue == 'Card Swipe Unit'){

g_form.addOption('request_type', choicevalue, choiceLabel);
g_form.addOption('request_type', choicevalue, choiceLabel);

}

}

 

Mark my answer correct & Helpful, if Applicable.

Thanks,

Sandeep

View solution in original post

5 REPLIES 5

Sourabh26
Giga Guru

Hi,

 

Both the fields are choice type?

 

Regards,

Sourabh

 

Yes both are choice type

 

Hi,

 

then you simply specify the dependent value to have only those values which are dependent on other choice field selection.

 

Ex. For Specialization field the choice is "Dermatology" (label) and value as "dermat"

then for Select doctor field (you need to show doc1 and doc2) then you need to select the dependent field value as "dermat".

 

Note : You can check the OOB functionality on incident table for Category & Sub category field.

Suppose if category is "Network" then the below sub category will appear only.

 

find_real_file.png 

 

Mark this as Helpful/Correct, if Applicable.

 

Regards,

Sourabh

Community Alums
Not applicable

Hi Priya,

You would require onchange client script on the select item variable; sample script below, just adjust or tweat as per your values:

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading) {
      return;
   }

g_form.clearOptions('request_type');

if(newValue == 'Card Swipe Unit'){

g_form.addOption('request_type', choicevalue, choiceLabel);
g_form.addOption('request_type', choicevalue, choiceLabel);

}

}

 

Mark my answer correct & Helpful, if Applicable.

Thanks,

Sandeep