Dynamically changing selected items in select boxe

Results 1 to 2 of 2

Thread: Dynamically changing selected items in select boxe

  1. #1
    Join Date
    Dec 1969

    Default Dynamically changing selected items in select boxe

    Does anyone know whether and how it is possible to alter the selected item in a select box based on the value in another select box? For example I create two select boxes on the page and when I select an item in the first an item in the second is automatically selected. I don&#039t mean that the options are redrawn but rather that the selected option is changed. Please help if you can.

  2. #2
    peterjl@austec.net.au Guest

    Default RE: Dynamically changing selected items in select

    The easiest way would be to submit the form when the value of the first select box is changed (i.e. use the onchange event), and generate the second select box via server-side ASP, based on the new value. <BR><BR>Otherwise, you could use client-side java to re-generate the second select box. You could store different sets of values in hidden text fields. Each set of hidden fields would be named to reflect the set they belong to, e.g.:<BR>&#060;form name=sets&#062;<BR>&#060;input type=hidden name=set1 value="val1.1"&#062;<BR>&#060;input type=hidden name=set1 value="val1.2"&#062;<BR>&#060;input type=hidden name=set1 value="val1.3"&#062;<BR><BR>&#060;input type=hidden name=set2 value="val2.1"&#062;<BR>&#060;input type=hidden name=set2 value="val2.2"&#062;<BR>&#060;input type=hidden name=set2 value="val2.3"&#062;<BR><BR>&#060;input type=hidden name=set3 value="val3.1"&#062;<BR>&#060;input type=hidden name=set3 value="val3.2"&#062;<BR>&#060;input type=hidden name=set3 value="val3.3"&#062;<BR>&#060;/form&#062;<BR>Note there are three sets and three members of each set. The three members of any set each have the same name. Your java script would loop through the members of that group the generate the list.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts