Select box dependent on another select box option
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 05:42 AM
Hi,
I have 2 select boxes and I need the 2nd select box dependent on the 1st select box.
Ex: If I choose 1 on the first select box then it should only show A on the second select box as an option
If I choose 2 on the first select box then it should only show B and C as the options for the second select box (A should not be part of the option).
I need this without creating tables or such.
Is it possible?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 06:07 AM - edited 11-11-2022 08:28 AM
Hi,
You can write onChange Client Script on the 1st Select box.
You can use g_form.addOption() and g_form.removeOption() based on the selection in onChange Script
Regards,
Karthik R
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 08:27 AM
Onchange client script on the First Select box
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
if (newValue == 'Type1') { // For 1st choice only option 'A' is added
g_form.addOption('Testbox', 'A', 'a'); //Fieldname,Nameofthechoice,value
g_form.removeOption('Testbox', 'B', 'b');
g_form.removeOption('Testbox', 'C', 'c');
g_form.removeOption('Testbox', 'D', 'd');
}
if (newValue == 'Type2') { //For choice 2 option 'B', 'C' are shown
g_form.addOption('Testbox','B','b');
g_form.addOption('Testbox','C','c');
g_form.removeOption('Testbox','A','a');
g_form.removeOption('Testbox','D','d');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 09:14 AM - edited 11-11-2022 09:44 AM
HI Karthik,
I messaged you the output.
Thanks,
Jonathan