[thelist] Multiple Selects in asp / javascript.

Jewel Mlnarik jewel at mlnarik.com
Tue Aug 24 11:30:49 CDT 2004


> The particular spec requires a series of radio buttons above 
> the select field to filter the select list - so that it only 
> shows records whose geographical location ID matches the one 
> checked by the radio box.

First, read this article on dymanic select lists.
http://www.quirksmode.org/js/options.html  Now you should know how to
add/subtract elements from a select list.

> I have a series of several hundred records which I need to display 
> in a <select> list. Each row is essentially a unique ID (which would 
> be the <option value="">) a concatenated field (which will be displayed 
> as the select list item <option>here</option> and a third value which 
> is a ID linking the record to the geographical location of which there are
8.

OK, so you'll most likely want to set up an array to hold all these values.
Let's say you set up 2:

 myOptions = new Array();
 myGeoLocations = new Array();
 // build out arrays ...

Both will have the "unique ID" as keys.  myOptions will hold values for the
display text -- so you can refer to it when building your select list.
myGeoLocations will hold values for the geo location ID (not sure what
you're using this for?).

Next, on a piece of paper, equate each radio button w/a group of the
"uniqueID"s.  You want to clearly define what options will be shown/hidden
when the radio button is selected/deselected.  Then you can create a "filter
array" associated w/each radio button.
  
  myFilter1 = new Array( id1, id2, id3, ...);
  myFilter2 = new Array( id4, id5, id6, ...);
  // build out filter arrays ...

Now you should have everything you need.  You'll call a function with every
radio button "onClick" or "onChange" that assesses the checked/unchecked
status of the radio button and then updates the select list accordingly. 

~jewel 




More information about the thelist mailing list