One drop down based on the other drop down

Results 1 to 4 of 4

Thread: One drop down based on the other drop down

  1. #1
    Join Date
    Dec 1969
    Posts
    38

    Default One drop down based on the other drop down

    Here is a situation:<BR>I have two drop down boxes and information in drop down 2 is based on drop down 1. Both of these drop down are getting info from database.<BR>exp: If I select 12:00 PM in drop down 1 then I should see 12:15PM and above in drop down 2<BR>Thanks for your help guys<BR>Vinay Bansal

  2. #2
    Matt Thesing Guest

    Default RE: One drop down based on the other drop down

    You are looking for some JavaScript.<BR><BR>Here is a link to the Cut-N-Paste JavaScript site. It does a triple-sync between three comboboxes. This should do what you want (with some modification).<BR><BR>http://www.infohiway.com/javascript/seasons.htm<BR><BR>You will have to create the JavaScript variables on the fly from your database data, but other than that it should be a simple matter to use the supplied example.<BR><BR> Matt <BR> (matt@onol.com)<BR>

  3. #3
    Scott Hickman Guest

    Default RE: One drop down based on the other drop down

    How do I create JavaSript variables on the fly from database data?

  4. #4
    Matt Thesing Guest

    Default RE: One drop down based on the other drop down

    Try something like this (may need a little bit of work, it is off the top of my head):<BR><BR>&#060;script&#062;<BR>var vCombo = new Array;<BR>&#060;%<BR> sKey = ""<BR> nKeyIndex = 0<BR> nIndex = 0<BR> While Not (RS.EOF)<BR> sValue = RS("VALUE")<BR> if (RS("KEY") &#060;&#062; sKey) then<BR> sKey = RS("KEY")<BR> nIndex = 0<BR>%&#062;<BR>vCombo[&#060;%=nKeyIndex%&#062;] = new Object;<BR>vCombo[&#060;%=nKeyIndex%&#062;].Key = &#039&#060;%=sKey%&#062;&#039;<BR>vCombo[&#060;%=nKeyIndex%&#062;].Values = new Array;<BR>&#060;%<BR> nKeyIndex = nKeyIndex + 1<BR> end if<BR>%&#062;<BR>vCombo[&#060;%=nKeyIndex%&#062;].Values[&#060;%=nIndex%&#062;] = &#039&#060;%=sValue%&#062;&#039;<BR>&#060;%<BR> nIndex = nIndex+1<BR> RS.MoveNext<BR> wend<BR>%&#062;<BR>&#060;/script&#062;<BR><BR>This just iterates through a recordset with two fields, KEY and VALUE. This assumes the KEY value goes in the first combo, and the corresponding VALUEs go in the second combo (and that the recordset is ordered by KEY).<BR><BR>When the first combo (master) selection changes, use some JavaScript code to get the index, which points into the vCombo[] array. Use the .Values[] member to get the values that should go into the second (slave) combo.<BR><BR>The code above will create the JavaScript variables that are used (on the fly). Sorry if my terminology was confusing.<BR><BR>Hope this helps.<BR><BR> Matt


Posting Permissions

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