- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2019 04:30 AM
Hi All,
On my catalog form, I have to variables A and B, both are select box type variables. Choices of B depends on A. Both variables are Mandatory, i.e. user has to select a value.
Variable B has 100's of choices for each choice of A. In the catalog client script for each choice of A I have to write many g_form.removeOption().
I tried using g_form.clearOptions() and then g_form.addOption(), this is working, but it is setting the first choice as default value, which shouldn't be the case. the user has to chose a choice each time.
Please let me know a best way to hide/remove 100's of choices at a time.
Regards,
Vasanth
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2019 09:05 AM
I've found the best method to be placing your desired drop down values into a table, where you have at least two fields, one for the values to display in your top drop down and one for the dependent values to display in the second. For a simple example you'd have a few records where column 1 is the first drop down value, and column 2 would be the values populated in the second drop down if that is selected.
column_1 | column_2
Hardware Accessories | Mouse
Hardware Accessories | Keyboard
Printer Accessories | Cable
Printer Accessories | Toner
Then, on your item, create two lookup select boxes.
On the first one (slb_1), set the reference qualifier to show the values from your table, column_1, and select unique values only.
On the second one (slb_2) show values from your table, column_2, but set your reference qualifier to filter results on column_1 = the current value of your first lookup select box. You also need to add a variable attribute that points to your first Select Box so that values are updated when a selection is made.
Your reference qualifier on slb_2 would look like: javascript: 'column_1=' + current.variables.slb_1
And your variable attribute would look like: ref_qual_elements=slb_1
The end result is, when you select "Hardware Accessories" from slb_1, the only options that show up in slb_2 are "Mouse, Keyboard".
Using this method has the added benefit of allowing you to change the options in both drop downs as data updates, rather than having to update variables directly or maintain a script.
Hope that helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2019 07:20 AM
If there's that many choices that matter, how come they're choice lists and not data tables?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2019 08:37 AM
Hi,
I will suggest to create the table and stores the data for choice A and B then change the type of variables to "Lookup Select box". To filter the values of choice B create the onChange Client script using glide ajax.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2019 06:12 AM
That can be solved by adding a blank entry right after "clearOptions":
g_form.clearOptions("variable_name");
g_form.addOption("variable_name", "", "-- Please Select --");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2019 09:05 AM
I've found the best method to be placing your desired drop down values into a table, where you have at least two fields, one for the values to display in your top drop down and one for the dependent values to display in the second. For a simple example you'd have a few records where column 1 is the first drop down value, and column 2 would be the values populated in the second drop down if that is selected.
column_1 | column_2
Hardware Accessories | Mouse
Hardware Accessories | Keyboard
Printer Accessories | Cable
Printer Accessories | Toner
Then, on your item, create two lookup select boxes.
On the first one (slb_1), set the reference qualifier to show the values from your table, column_1, and select unique values only.
On the second one (slb_2) show values from your table, column_2, but set your reference qualifier to filter results on column_1 = the current value of your first lookup select box. You also need to add a variable attribute that points to your first Select Box so that values are updated when a selection is made.
Your reference qualifier on slb_2 would look like: javascript: 'column_1=' + current.variables.slb_1
And your variable attribute would look like: ref_qual_elements=slb_1
The end result is, when you select "Hardware Accessories" from slb_1, the only options that show up in slb_2 are "Mouse, Keyboard".
Using this method has the added benefit of allowing you to change the options in both drop downs as data updates, rather than having to update variables directly or maintain a script.
Hope that helps.