Active Server Pages Programming (ASP)/VBS onChange Run SQL statment
Expert: Ashley Brazier - 2/6/2009
QuestionI am not sure if this can be done but I will ask.
I have a List/Menu field "txtMan" that has VB Script Command I would like to run onChange.
I am new to this style of programing and I could be missing something.Can this be done?
Code:
<script language="vbs">
Sub txtMan_onchange()
<%Dim Apples
Set Apples = Server.CreateObject("ADODB.Connection")
ConnStr = "DRIVER={Microsoft Access Driver (*.mdb)}; "
ConnStr = ConnStr & "DBQ=" & Server.MapPath("xr4ti\SDB.mdb")
Apples.Open(ConnStr)
SQLtemp = "SELECT txtname, txtuseremail FROM tblUser WHERE txtname = '" & Request.form("txtMan.value") & "' "
Set rs = Apples.Execute(SQLtemp)
Do while not rs.eof%>
frmwrnew.txtManEmail = rs("txtuseremail")
<%
rs.MoveNext
Loop
rs.Close
Apples.Close
set Apples = Nothing
%>
End Sub
</script>
Thanks,
C
AnswerHi,
If you were to do this in .NET it wouldn't be a problem as the onChange is an event on a control.
In ASP you would have to put some javascript on the onchange event which would then do a postback. On the postback look out for the changed value and run your script.
Does that help?