2
<%@ 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.

1
  • you usually do this with an Ajax request. Commented Jan 21, 2014 at 9:03

2 Answers 2

5

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

Sign up to request clarification or add additional context in comments.

4 Comments

Strictly speaking it's Classic ASP which runs on the server. You can use VBScript or Javascript as your scripting language in Classic ASP. You can also run VBScript client side in the same way as Javascript, but only IE supports it
Yes, this is true, but anyone doing this is crazy.
You find client side VBS on intranets more often that you might imagine :(
@Diodeus Sorry but "VBScript runs on the server" is not accurate and might be misleading. "Classic ASP runs on the server" is more correct, I considered editing but it better be done by you.
3

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.