Active Server Pages Programming (ASP)/VBS onChange Run SQL statment

Advertisement


Question
I 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

Answer
Hi,

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?

Active Server Pages Programming (ASP)

All Answers


Answers by Expert:


Ask Experts

Volunteer


Ashley Brazier

Expertise

Main focus is ASP, SQL Server 2000 & 2005

Experience

Over 6 years experience.

Education/Credentials
BCs Honours Software Design and Networks

©2012 About.com, a part of The New York Times Company. All rights reserved.