multiple combos filled from other combos
Hi guys,
I've got 3 set of combos (kind of city -> zip-code) and I fill both from DB. selecting a value from the first one I fill the second one with the appropriate zip-code. Everything works fine, but my problem is that because I've got 3 set of combos, I have to refresh the page every time somebody selects one of the first combos, and I loose the other data of the form!
I tried with a pop-up, but the page must refresh, mustn't it???!! Please help, I'm not so good at "javascript".
Here is my code:
...........................................
<SCRIPT LANGUAGE=javascript>
<!--
function DoClose(tipo)
{
//this fun. sends to the main page the values selected
//into the popup as querystring format
window.opener.location.replace("./" + window.document.form1.PAG.value + "?TIPO=" + tipo + "&" + window.document.form1.wichCity.value + "=" + window.document.form1.city.value + "&" + window.document.form1.wichZip.value+ "=" + window.document.form1.zip.value);
window.close();
}
function getZipCode()
{
window.location.reload('getZip.asp?PROV=' + window.document.form1.city.value);
}
//-->
</SCRIPT>
<select name="provincia" onChange="return getProvincia();" onSelect="return getProvincia();">
<%
set rsPr = server.CreateObject("ADODB.recordset")
rsPr.Open "select * from TB_CITY order by sigla",objConn,3,1
strSelected = ""
while not rsPr.eof
if rsPr("sigla") = session("CITY") then
strSelected = "selected"
else
strSelected = ""
end if%>
<option value="<%=rsPr("sigla")%>" <%=strSelected%>>
<%=rsPr("city")%>
</option>
<%rsPr.MoveNext
wend
strSelected = ""
rsPr.Close
set rsPr = nothing%>
</select>
<%
set rsCom = server.CreateObject("ADODB.recordset")
rsCom.Open "select * from TB_ZIPCODE where rif_city = '" & _
session("CITY") & "' order by comune",objConn,3,1%>
<select name="comune" onChange="return doClose(<%=session("tipo")%>);" onSelect="return doClose(<%=session("tipo")%>);">
<%if rsCom.RecordCount > 0 then
while not rsCom.eof%>
<option value="<%=rsCom("zip")%>">
<%=rsCom("zip")%>
</option>
<%rsCom.MoveNext
wend
rsCom.Close
set rsCom = nothing
else%>
<option value ="-1">Select a city</option>
<%end if%>
</select>
<input type="hidden" name="QUALEPR" id="QUALEPR" value="<%=session("qualeProv")%>">
<input type="hidden" name="QUALECOM" id="QUALECOM" value="<%=session("qualeCom")%>">
<input type="hidden" name="PAG" id="PAG" value="<%=session("pag")%>">
|