What is the best way to hide 100's of choices in the select box type variable on catalog form.

Vasanth Pandia1
Tera Contributor

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

1 ACCEPTED SOLUTION

miked_jones
Giga Expert

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. 

 

 

View solution in original post

6 REPLIES 6

Thanks. I Did the same it is working.

 

Regards,

Vasanth

lakin nosao
Kilo Explorer

The end result is, when you select "Hardware Accessories" from slb_1, the only options that show up in slb_2 are "Mouse, Keyboard, printer".