- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2023 07:15 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2023 07:42 AM - edited ‎05-24-2023 07:42 AM
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');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2023 07:22 AM
You probably don't need a client script, on the choice field add the dependent value
For S1 & S2 make the dependent value as A
For S3 & S4 make the dependent value as B
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2023 07:26 AM
The requirement is on the script so I would like to know the script for this solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2023 07:37 AM
Dear @Souvick A
You have to check value of the Cat, base on that you have tom use g_form.addOptions and removeOption
Note: better solution to use dependent value in choice table.
Please feel to ask any questions in case any queries.
- Kailas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2023 07:05 AM
Below is my onchange client sript. It is working for option A, but for option B it is showing all the options
Can I get help on this. Also , the choice table logic is new , so in order to configure that, what will be the table name for variables