|
-
Mar 27th, 2001, 04:09 AM
#1
Thread Starter
Addicted Member
Dear all,
How to define a sub or function in ASP environment?
For e.g. file name is test.asp
When I click the "cmdAnswer" button, I want it to call
"Answer" procedure/sub/function
The code below doesn't work. It always prompts me
"Answer is undefined".
Can anybody help me on this?
<%
Sub Answer
Response.Write ("Hello World")
End Sub
Response.Write ("<input type=button value=AnswerMe name=cmdAnswer onClick='Answer'>")
%>
Thanks in advance
Keiko
-
Mar 27th, 2001, 04:58 AM
#2
Fanatic Member
Hi keiko.
your problem is that you are trying to use ASP as client side script. ASP is purely for server side programming. try using the following Javascript to sort out you problem
<HTML>
<HEAD>
<script language="javascript">
function Answer()
{
alert('Hello World');
}
</script>
</HEAD>
<BODY>
<input type=button value=AnswerMe name=cmdAnswer onClick='Answer();'>
<BR>
</BODY>
</HTML>
THis will call answer when the button is pressed
Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!
-
Mar 27th, 2001, 05:26 AM
#3
Thread Starter
Addicted Member
Thanks for the reply Ianpbaker,
But I'm using ASP to hide some information.
Anyone else can help me?
-
Mar 27th, 2001, 05:55 AM
#4
Fanatic Member
Keiko. You will never be able to call that sub with the above code as you are trying to call a server side sub from the clients machine as ASP is not dynamic like that. THe server will procees your page and then terminate, with the client knowing nothing about the sub. what exactly are you trying to do?
Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|