For MUlTIPLE categories value apply IN CATALOG CLIENT SCRIPT?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2024 01:41 PM
Hi Everybody,
I am stuck using these script.where is issue could any one suggest on its.
ONLY new value== A is working all these
Thanks
Angel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2024 07:00 PM
In the else statement, you have used (newValue == ' E'), which should be else if (newValue == 'E'). You don't need parentheses for else statements.
There's a duplicate removeOption for category '6' in the 'D' section.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
// Type appropriate comment here, and begin script below
var cat = g_form.getValue('category');
if (newValue == 'A') {
g_form.clearOptions('category');
g_form.addOption('category', '', '-- None --');
g_form.addOption('category', '1', '1');
g_form.addOption('category', '2', '2');
g_form.removeOption('category', '3', '3');
g_form.removeOption('category', '4', '4');
g_form.removeOption('category', '5', '5');
g_form.removeOption('category', '6', '6');
g_form.removeOption('category', '7', '7');
} else if (newValue == 'B') {
g_form.clearOptions('category');
g_form.addOption('category', '', '-- None --');
g_form.addOption('category', '3', '3');
g_form.addOption('category', '4', '4');
g_form.removeOption('category', '1', '1');
g_form.removeOption('category', '2', '2');
g_form.removeOption('category', '5', '5');
g_form.removeOption('category', '6', '6');
g_form.removeOption('category', '7', '7');
} else if (newValue == 'C') {
g_form.clearOptions('category');
g_form.addOption('category', '', '-- None --');
g_form.addOption('category', '5', '5');
g_form.removeOption('category', '1', '1');
g_form.removeOption('category', '2', '2');
g_form.removeOption('category', '4', '4');
g_form.removeOption('category', '6', '6');
g_form.removeOption('category', '7', '7');
} else if (newValue == 'D') {
g_form.clearOptions('category');
g_form.addOption('category', '', '-- None --');
g_form.addOption('category', '6', '6');
g_form.addOption('category', '7', '7');
g_form.removeOption('category', '1', '1');
g_form.removeOption('category', '2', '2');
g_form.removeOption('category', '3', '3');
g_form.removeOption('category', '4', '4');
g_form.removeOption('category', '5', '5');
} else if (newValue == 'E') {
g_form.clearOptions('category');
g_form.addOption('category', '', '-- None --');
g_form.addOption('category', '1', '1');
g_form.addOption('category', '2', '2');
g_form.addOption('category', '3', '3');
g_form.addOption('category', '4', '4');
g_form.addOption('category', '5', '5');
g_form.addOption('category', '6', '6');
g_form.addOption('category', '7', '7');
}
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2024 11:26 AM
this is not working only first value which is A work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2024 07:11 PM
Try to give some alerts in every if-else block and also change the new value to B or C or D while testing and observe the alerts.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2024 02:35 AM
Could you please let me know on which variable you have kept the On-Change of this script ? If possible, can you please share some screenshots.
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.