How to make dependency value from the choice table on Catalog ITEM.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2023 04:31 AM - edited 11-29-2023 04:32 AM
Hi Team,
I have created two Elements : ElementA and ElementB with choice list.
Note : Field names : u_element_a , u_element_b
I need to populate only B1, B2 when selected A1, and Populated B2,B3 when selected A2 like wise.
Created below Catalog Client Script can't fix this issue. Can some one please help with script.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
function onChangeElementA() {
var elementAValue = g_form.getValue('u_element_a');
setChoicesForElementB(elementAValue);
}
function setChoicesForElementB(elementAValue) {
var choicesForElementB = getChoicesForElementB(elementAValue);
g_form.clearOptions('u_element_b');
g_form.addOptions('u_element_b', choicesForElementB);
}
function getChoicesForElementB(elementAValue) {
var choices = [];
if (elementAValue == 'A1') {
choices = ['B1', 'B2'];
} else if (elementAValue == 'A2') {
choices = ['B2', 'B3'];
} else if (elementAValue == 'A3') {
choices = ['B3', 'B1'];
}
return choices;
}
g_form.observe('u_element_b', onChangeElementA);
}
----------------------------------------------------------------------------------