Generating a listbox from a listbox w/out hardcodi

Results 1 to 3 of 3

Thread: Generating a listbox from a listbox w/out hardcodi

  1. #1
    Stew Guest

    Default Generating a listbox from a listbox w/out hardcodi

    Hi! I am terrible with Javascript and I was wondering if someone could help me with a problem I have. I want to have two list boxes on a form. When you pick an element in one, the other displays a list related to what was picked in the first. Do you follow? Ok here is the kicker though. I know how to hard code it, however, I need to create it on the fly.. in an ASP page. I found a tutorial at this address:<BR>However, I don&#039t really follow this too well. I can get mine to work partially, but I know that I am doing something wrong. <BR>If some kind person out there would take a look at that and explain it to me as though I knew absolutely nothing about it, I would be very very very very very greatful. MANY THANKS IN ADVANCE!!!!!<BR><BR>-Stew

  2. #2
    Join Date
    Dec 1969

    Default RE: Generating a listbox from a listbox w/out hard

    Well, I am about done with code that does 3 dynamically linked listboxes so i am sure I can help. List your code here and tell me what is not working.<BR><BR>Thanks

  3. #3
    Stew Guest

    Default RE: Generating a listbox from a listbox w/out hard

    here we go...ready??? **Disclaimer** As I said before, I really don&#039t know too much about JavaScript, so I really have no idea as to what exactly is going on below. Also, I suspect that I might be doing the join wrong too....Let me know. Many thanks!<BR> &#060;html&#062;<BR>&#060;body&#062;<BR>&#060;f orm name="f1"&#062;<BR>&#060;%<BR><BR>Set objConn = Server.CreateObject("ADODB.Connection")<BR>objConn .open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.Mappath("./db2.mdb")<BR>Set rsX = Server.CreateObject("ADODB.Recordset")<BR>sQuery = "SELECT DISTINCT regions.region,,, jobs.region, jobs.title FROM regions INNER JOIN jobs ON ="<BR>rsX.Open sQuery, objConn, adCmdText<BR>If rsX.EOF Then<BR> Response.Write "No selections.<BR>"<BR>Else<BR> Response.Write "&#060;SELECT NAME=""manufacturer"" SIZE=15" & _<BR> " ONCHANGE=""manuselected(this);"" &#062;"<BR> sJavaScript = "function manuselected(elem){" & vbCrlf & _<BR> "for (var i = document.f1.model." & _<BR> "options.length; i &#062;= 0; i--){" & vbCrlf & _<BR> "document.f1.model.options[i] = null;" & _<BR> vbCrlf<BR> Do Until rsX.EOF<BR> If sLastManufacturer &#060;&#062; rsX("region") Then<BR> sLastManufacturer = rsX("region")<BR> Response.Write "&#060;OPTION VALUE=" & rsX("office") & _<BR> "&#062;" & sLastManufacturer & "&#060;/OPTION&#062;"<BR> sJavaScript = sJavaScript & "}" & vbCrlf & _<BR> "if (elem.options[elem.selectedIndex].value==" & _<BR> rsX("office") & "){" & vbCrlf<BR> End If<BR> sJavaScript = sJavaScript & _<BR> "document.f1.model.options[document." & _<BR> "f1.model.options.length] = new Option(&#039" & _<BR> rsX("office") & "&#039,&#039" & rsX("title") & "&#039);" & _<BR> vbCrlf<BR> rsX.MoveNext<BR> Loop<BR> Response.Write "&#060;/SELECT&#062;"<BR> Response.Write "&#060;SELECT NAME=""model"" SIZE=15&#062;"<BR> Response.Write "&#060;OPTION&#062;[none currently selected]&#060;/OPTION&#062;"<BR> Response.Write "&#060;/SELECT&#062;"<BR> sJavaScript = sJavaScript & vbCrlf & "}" & vbCrlf & "}" & vbCrlf<BR> Response.Write "&#060;SCR" & "IPT LANGUAGE=""JavaScript""&#062;" & vbCrlf<BR> Response.Write sJavaScript & vbCrlf & "&#060;/SCR" & "IPT&#062;" & vbCrlf<BR>End If<BR>rsX.Close<BR>Set rsX = Nothing<BR><BR>%&#062;<BR>&#060;/form&#062;<BR>&#060;/body&#062;<BR>&#060;/html&#062;

Posting Permissions

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