Add options based on choices

latha13
Tera Contributor

Hi,

In a catalog item i have Multiple Choice field  (New and old choices in multiple choice field)

In that catalog item i have multi row variable set(Accessing) in that there is a field access(Multiple choice field) and choices are Grade1 and Grade2..Now Req is :

Under New -> Accessing(multirow variable set)-> access : Should only have Grade1

Under Old-> Accessing(multirow variable set)-> access  : Should have both Grade1& Grade2( As it is) Mandatory

I tried with on change client script :

g_form.clearOptions('access');

if(newValue=='New')
{
g_form.addOption('access','Grade1 ');
g_form.removeOption('access','Grade2');
}
else if(newValue=='Old')
{
g_form.addOption('access','Grade1 ');
g_form.addOption('access','Grade2');

}

 

6 REPLIES 6

Allen Andreas
Administrator
Administrator

Hi,

For multiple choice fields...I don't believe you're able to "addOption" for that...so do you mean select-box?

Either way, for addOption, the appropriate format is:

g_formaddOption(<fieldName>, <choiceValue>, <choiceLabel>, <targetIndex>); 

With "targetIndex" being 1 or 2 or 3, etc. the order in which you want it to appear in your select-box list of choices.

Also for your "newValue"....ensure are using the actual value of the choice...so is it 'New' or 'new'?

Either way, you should have enough here to proceed successfully!

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi,

I just wanted to check-in on this.

If my reply above helped guide you correctly, please mark it as Helpful & Correct.

Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

I do believe that addOption is not avaiable for Multiple choice variable.

Can you suggest me a way to add choices on a variable based on another variable.

For example i want to display the different states based on the country choice on a catalog item variable set.

Hello,

Please create a new question on the forums and feel free to mention me @Allen A for assistance.

Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!