Onchange of varaibles remove option is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2019 02:19 AM
Hello All,
i have created onchange client script to remove option based other variable but it is not working as expected please provide your inputs on it below is my scenario.
Two Variables of type select box A and B
A has two choices x and y
B has two choices p and q
if we select x under A only p has to display for B
for y we need to display both values of B
i have created a script of onchange when we select x under A only one values is showing working fine but when changing back to y B has to display both values but it is not happening .
Please provide me with workaround
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2019 05:00 AM
Hi,
Please use below on change script
if(newValue=="x")
{
g_form.RemoveOption("B","p');
g_form.AddOption("B","q");
}
else
{
g_form.RemoveOption("B","q');
g_form.AddOption("B","p");
}
Hope this works
Regards

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2019 03:30 AM
Hi,
As per your requirements try following onChange Client Script.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(newValue == 'X'){
g_form.removeOption('u_field_b','Q');
g_form.addOption('u_field_b','P', 'P');
}
if(newValue == 'Y'){
g_form.addOption('u_field_b','P', 'P');
g_form.addOption('u_field_b','Q', 'Q');
}
}
If its helpfull mark it correct.
Regards,
Vaibhav Chaudhari