Reputation: 153
<%@ language = "VBScript"%>
<!DOCTYPE html>
<html>
<body>
<form method="post" action = "">
<input type = "submit" onclick = "check()" value = "Submit"/>
</form>
<%
sub check()
Response.write("TEST")
end sub
%>
</body>
</html>
When I click on the submit button, this doesn't print "TEST" for some reason.
Upvotes: 2
Views: 20772
Reputation: 114367
Classic ASP runs on the server. Click events happen on the client. There is no persistent connection between the two. Web programming is not the same as desktop app programming.
At a basic level, your code needs to follow this pattern:
BROWSER - click -> request to server -> server processes request -> serves new page -> BROWSER
Upvotes: 5
Reputation: 4638
An onclick event won't work server side for the reasons Diodeus explains. .You need to use the Request object to collect form data. This should do what I think you're trying to achieve.
<%@language="VBScript"%>
<!DOCTYPE html>
<html>
<body>
<form method="post">
<input type = "submit" name="mybutton" value = "Submit"/>
</form>
<%
If Request.Form("mybutton") <> "" then
Response.write("TEST")
End If
%>
</body>
</html>
Upvotes: 4