 | 
October 5th, 2008, 04:54 PM
| | Newbie | | Join Date: Oct 2008 Location: earth Age: 24
Posts: 4
| | Calling javascript function from asp - <SCRIPT LANGUAGE="JavaScript">
-
function enb() {
-
document.form1.send.disabled=false
-
}
-
</SCRIPT>
i need to call the above function in asp page and inside if /else
i try javascript:enb()
and enb()
and call enb()
all didnt work can any one give me advice
Last edited by jhardman; October 6th, 2008 at 06:38 PM.
Reason: put code in code tags. please note button marked #
| 
October 6th, 2008, 10:39 AM
| | Newbie | | Join Date: Oct 2008
Posts: 12
| |
The problem is that you have no event to fire the function.
Try.. - <%
-
test = 1
-
%>
-
-
<html>
-
<head>
-
-
<SCRIPT LANGUAGE="JavaScript">
-
function enb() {
-
document.form1.send.disabled=true;
-
}
-
</SCRIPT>
-
</head>
-
<body
-
<%
-
IF test=1 THEN
-
%>
-
onLoad="enb()"
-
<%
-
ELSE
-
%>
-
-
<%
-
END IF
-
%>
-
>
-
-
<form name="form1" id="form1" action="test.asp?action=called" method="GET">
-
-
<input type="button" name="send" id="send" value="send" />
-
-
</form>
-
-
</body>
-
</html>
Last edited by jhardman; October 6th, 2008 at 06:40 PM.
Reason: put code in code tags. please note button marked #
| 
October 6th, 2008, 06:36 PM
|  | Moderator | | Join Date: Jan 2007 Location: logan, utah Age: 32
Posts: 2,374
| |
Snester is right, and this is actually a common goof. You see, ASP is executed on the server and javascript is executed on the browser. Snester's approach of adding the javascript function call to the body onload event (conditionally, using asp) is the best way to solve this problem.
Jared
| 
October 7th, 2008, 08:33 AM
| | Newbie | | Join Date: Oct 2008 Location: earth Age: 24
Posts: 4
| |
Thanks for your answer about calling tha javascript but im still in same problem i need to enable the send button in the page after checking the captcha text without submitting all the form content so i need to call the javascript function from server side
| 
October 7th, 2008, 04:36 PM
|  | Moderator | | Join Date: Jan 2007 Location: logan, utah Age: 32
Posts: 2,374
| |
You can't. Javascript is executed on the client, not on the server. I know of no captcha that is processed with javascript. There is not an active connection between the browser and the server, the form has to be submitted after the captcha is filled in order for the server to see what the user entered. It might be possible to do something like this with ajax, but then you would be asking in the wrong forum.
Jared
| 
October 7th, 2008, 05:36 PM
|  | Moderator | | Join Date: Jan 2008 Location: Winchester, UK
Posts: 924
| |
If I've understood you correctly then you could 'disable' the button by checking the condition that decides whether or not to display it and if it's true write the html that displays it. If it's not true then you can display an image that looks like the disabled button instead.
Not sure if this sorts your problem out as i'm answering this in a hurry but I hope so :-)
Dr B
| 
October 8th, 2008, 05:58 PM
|  | Moderator | | Join Date: Jan 2007 Location: logan, utah Age: 32
Posts: 2,374
| |
DrB, I think he is saying he has a "captcha" or "text capture to block automated submissions" and he wants to check it against a value on the server while neither submitting the whole form nor putting the correct answer anywhere on the page (he doesn't want the javascript function to have the answer). Using just ASP you would need to submit the whole form to check the "captcha". It is possible that this sort of thing could be handled with Ajax, but I definitely don't know how to do that.
Jared
|  |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over network members.
|