Pessoal, estou usando ASP com js e tenho o seguinte probl.
qdo eu selecionar uma opção em um combo preciso que seja feito um select no banco pelo ASP, tentei colocar no metodo onchange do combo o submit do form para que seja executado o select…porém não funciona…alguém pode me ajudar?!
<%
Dim Conn, RS, SQL, objRecordset, SQL2, RS2
Dim xQtde, xK, xLat(100), xLong(100), xEndereco(100), xOrdemEnd(100)
Dim xLinha, xIdaVolta
xQtde = 0
Set Conn = Server.CreateObject("ADODB.Connection")
Set objRecordset = Server.CreateObject("ADODB.Recordset")
Conn.Open strMySQL
SQL2 = "Select NUM_LINHA, DESC_LINHA from LINHA_BUS order by NUM_LINHA"
Set RS2 = Conn.Execute(SQL2)
Response.Write "<select name='Linha' size=1 onchange='form.submit()'>"
Response.Write"<OPTION>-Selecione a Linha-</OPTION>"
do while not RS2.EOF
Response.Write"<OPTION "
if CInt(Request.Form("Linha"))= RS2(0) then
Response.Write"selected "
end if
Response.Write"value='"&RS2(0)&"'>"&RS2(0)&"</OPTION>"
RS2.MoveNext
loop
Response.Write"</SELECT>"
xLinha = Request.form("Linha")
xIdaVolta = Request.form("Ida_Volta")
=======esse select deverá ser executado após a seleção do combo======================
if xLinha <> "-Selecione a Linha-" and xLinha <> null then
SQL = "Select * from ITINERARIO where LINHA_ITI="&xLinha&" and IDA_VOLTA='"&xIdaVolta&"' order by ORDEM_END"
Set RS = Conn.Execute(SQL)
while not RS.EOF
xQtde = xQtde + 1
xEndereco(xQtde) = RS("ENDERECO")
xLat(xQtde) = RS("LAT")
xLong(xQtde) = RS("LONGIT")
xOrdemEnd(xQtde) = RS("ORDEM_END")
RS.movenext
wend
for xK=1 to xQtde
Response.Write("<script>latitude='"&xLat(xK)&"'; longitude='"&xLong(xK)&"'; End='"&xEndereco(xK)&"'; ordem='"&xOrdemEnd(xK)&"';Qtde='"&xQtde&"'; i='"&xK&"'; passa_val(latitude, longitude, End, ordem, Qtde, i);</script>" )
next
RS.close
end if
RS2.close
%>
no onsubmit chamo a função que deveria ser executada após o select
<form action="linha_bus.asp" name="linha_onibus" method="post" onsubmit="passa_val()">
a função passa_val serve apenas para passar os valores das variáveis ASP para as variáveis JS
function passa_val(latitude, longitude, End, ordem, Qtde, i)
{
lat[i] = latitude;
lng[i] = longitude;
name[i] = End;
date[i] = ordem;
}
alguém sabe como fazer para que eu consiga executar o select?!
obrigada!!