![]() |
| |||||||
| Sponsored Links |
![]() | « Previous Thread | Next Thread » |
| | LinkBack | Thread Tools | Display Modes |
|
#1
| |||
| |||
| Hi, I have to populate a drop down based on the value selected from an earlier drop down. I cant do a page submit or refresh I have to do it in javascript the second drop down will be populated from the table here is my code for first drop down can someone tell me how i can open up a recordset for the second drop using javascript Code: <select name="Sport" id="Sport" size="1">
<option value="">Select Sport</option>
<%
strsport = "SELECT * from Sports order by SportName"
Set Rssport = Conn.Execute(strsport)
if not Rssport.eof then
Do while not Rssport.Eof
%>
<option value="<%=Rssport("SportName")%>"><%=Rssport("SportName")%></option>
<%
Rssport.movenext
loop
End if
Rssport.close
Set Rssport=Nothing
%>
</select>
|
| Sponsored Links |
|
#2
| ||||
| ||||
| You can't. You'd have to use AJAX since the ASP script runs on the server, not the client. See Mega site of Bible studies and information for an AJAX intro.
__________________ Wolffy ------------------------ Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary. |
|
#3
| ||||
| ||||
| Okay, time to rant. I HATE spaghetti code. It is ugly, hard to read, and just plain sucks. So, what I like to do, is to create SUBS. This way, you can globalize them and use them on one, or many pages. Also, why are you passing the SportName as the value of the dropdown. You should ALWAYS use the unique ID for that SportName. Anyways, I didn't tinker with that, but here you go: Code: Sub SelectSport(SportName)
' -- Create SQL --
strSQL = "SELECT SportName FROM Sports ORDER BY SportName"
Set rsSport = conn.Execute(strSQL)
' -- Create Dropdown --
response.write "<select name=""sport"" id=""sport"" size=""1">" & vbCrLf
response.write "<option value="""">Select Sport</option>" & vbCrLf
' -- Loop Through RS --
If Not rsSport.EOF Then
Do While Not rsSport.EOF
response.write "<option value=""" & rsSport("SportName") & """"
If CStr(SportName) = CStr(rsSport("SportName")) Then
response.write " selected"
End If
response.write ">" & rsSport("SportName") & "</option>" & vbCrLf
rsSport.MoveNext
Loop
End If
' -- Close Dropdown --
response.write "</select>" & vbCrLf
' -- Close Connection --
rsSport.Close
End Sub
Code: SportName = Request.Form("sport")
Call SelectSport(SportName)
__________________ "You'll never be as perfect as BLaaaaaaaaarche." |
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| drop down problem | todd2006 | JavaScript Programming | 32 | July 1st, 2008 04:46 PM |
| display problem with drop downs | todd2006 | JavaScript Programming | 3 | May 5th, 2008 05:31 PM |
| drop down problem | todd2006 | .Net Development | 2 | April 23rd, 2008 11:37 AM |