Hi,
I tryed this code, it works.
problem is,
Due to refresh of the page, The first Drop down does not show the value
last selected.
is there any way we can trap and keep the index selected, so i can then
send both the values from the drop down to some other page.
help please.
> You have to set your Response.Buffer = True before you write the
> <head></head> tags. Then using javascript/vbscript to watch for changes
in
> one of the dropdown boxes. Example code follows:
>
>
> >>>>>>>>>>>>Begin code<<<<<<<<<<<<<<<
>
> <%
> Response.Buffer = True
> %>
>
> <head>
> <title . . </title>
> <script language='javascript'>
> function dynamicSelect()
> {
> n = document.forms[0].dropdown_one.selectedIndex;
> document.location = "thispage.asp?firstbox=" +
> document.forms[0].dropdown_one(n).value;
>
> return true;
> }
> </script>
> </head>
>
> blah \
> blah | HTML code
> blah /
>
> <form method='post' action='whatever.asp'>
> <select name='dropdown_one' onChange='return dynamicSelect()'>
> <%
> Dim cmdData, recData
> Set cmdData = Server.CreateObject("ADODB.Command")
> Set recData = Server.CreateObject("ADODB.Recordset")
> cmdData.ActiveConnection = "DSN=database_dsn;"
> cmdData.CommandText = "SELECT table_key, record_name FROM database_table
> WHERE criteria = '" & varCriteria & "'"
> Set recData = cmdData.Execute
> While Not recData.EOF
>
> Response.Write "<option value='" & recData("table_key") & "'>" &
> recData("record_name") & "</option>"
> recData.MoveNext
> Wend
> %>
> </select>
>
> <select name='dropdown_two'>
> <%
>
> cmdData.CommandText = "SELECT * FROM second_database_table WHERE
> criteria='" & Request.Querystring("firstbox") & "'"
> Set recData cmdData.Execute
> While Not recData.EOF
>
> Response.Write "<option value='" & recData("table_key") & "'>" &
> recData("record_name") & "</option>"
> recData.MoveNext
> Wend
> %>
> </select>
>
> >>>>>>>>>>>>>>>>>>>End
Code<<<<<<<<<<<<<<<<<<<<<<
>
>
>
> This will dynamically fill the first drop down box and when a user
selects
> something from the first dropdown box, the form will reload and the
second
> dropdown box will be fill based on the criteria selected in the second
box.
>
> Notice that we reuse the cmdData and recData server objects. This
doesn't
> hurt anything and it reduces the resource load on the server.
>
> KD
>
> Kevin D Riggs
>
> kevin.riggs@p...
>
> Senior Network Administrator & Webmaster
> Rhea County
> Board of Education
>
> http://www.rhea.k12.tn.us/
> http://www.rheacounty.org/