I'm trying to give completely different options in the second drop down box depending upon what is selected in the first.
I have done part of code, but don't know what's wrong with the code, it can't display any option in the second box, would you help me to check it, please?
<table width="100%" border="0" align="left">
<tr><td colspan="2">
<form name="partslocator">
<table border="0" cellspacing="0" cellpadding="0">
<tr><td>
<b>Step 1.</b>
</td>
<td>
<select name="model" size="1" onChange="redirect(this.options.selectedIndex);">
<option selected> Select Category Type </option>
<%
myconn = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & server.mappath("NewsData.mdb"

& ";"
myquery="select distinct Category from Category"
dim conntemp, rstemp
set conntemp=server.createobject("adodb.connection"

conntemp.open myconn
set rstemp=conntemp.execute(myquery)
do while not rstemp.eof
fieldfirst=RStemp(0)
if isnull(fieldfirst) or fieldfirst="" then
' ignore
else
response.write "<option value='" & fieldfirst
response.write "'>" & fieldfirst & "</option>"
end if
rstemp.movenext
loop
%>
</select>
<%
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
%>
</td></tr>
<tr><td>
<b>Step 2.</b>
</td>
<td>
<select name="availablemodels" size="1">
<option value="#" selected> Select the Category first </option>
</select></td></tr></table></form>
<script>
var groups=document.partslocator.model.options.length
var group=new Array(groups)
for (i=0; i<groups; i++)
group
=new Array()
group[0][0]=new Option("Select Model"
;
<%
myconn = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & server.mappath("NewsData.mdb"
& ";"
myquery="select MICode from Category where Category='" &model& "'"
dim conntemp1, rstemp1
set conntemp1=server.createobject("adodb.connection"
conntemp1.open myconn
set rstemp1=conntemp1.execute(myquery)
j=1
do while not rstemp1.eof
k=0
MICode=RStemp1("MICode"
%>
group[<%=j%>][<%=k%>]=new Option("<%=MICode%>"
;
<%
j=j+1
rstemp1.MoveNext
loop
rstemp1.close
%>
var temp=document.partslocator.availablemodels
function redirect(x)
{
for (m=temp.options.length-1; m>0; m--)
temp.options[m]=null
for (i=0; i<group[x].length; i++)
{
temp.options=new Option(group[x].text,group[x].value)
}
temp.options[0].selected=true
}
</script>
Thank you for your advise!!
Ribena