simple button to run function = type mismatch

G

Gordon

I'm just getting started in ASP and can't seem to figure out how to
run a function in ASP. I get an error of "Line 11 - Type
Mismatch:'myvalidate'.
Line 11 is the Input Button.
Here is my simple page's code, what's wrong???:

<%@LANGUAGE="VBSCRIPT"%>
<%
sub myvalidate()
response.write("ok")
response.end
end sub
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>


<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
<input type="text" name="txt">
<input language = "VBSCRIPT" type="button" name="myButton"
value="Button" onClick="Call myvalidate()">
</form>
</body>
</html>
 
R

Ray at

Onclick is a client-side event, the browser that you're using is looking in
the source of your page for a function named myvalidate. As you'll see in a
view-source, there is no function with that name. That function only exists
at the server level in the server-side code, and the browser will never have
any knowledge of it. For this particular example, you could do a
document.write (client side code), but I imagine your ultimate goal is to
just test calling a subroutine, not writing "ok."

Getting a grip on client-side code and server-side code is one of the first
steps in ASP. But, if you pretend your the server for a minute, you'll see
that anything that exists outside of server side script blocks (<% %>, for
example) is just a meaningless string of characters, regardless of its
content. That might make sense. I'm a lousy teacher. :]

Ray at home
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,076
Latest member
OrderKetoBeez

Latest Threads

Top