473,394 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Calling javascript function from asp

Expand|Select|Wrap|Line Numbers
  1. <SCRIPT LANGUAGE="JavaScript">
  2. function enb() {
  3. document.form1.send.disabled=false
  4. }
  5. </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
Oct 5 '08 #1
6 18916
snester
12
The problem is that you have no event to fire the function.

Try..
Expand|Select|Wrap|Line Numbers
  1. <% 
  2. test = 1
  3. %>
  4.  
  5. <html>
  6. <head>
  7.  
  8. <SCRIPT LANGUAGE="JavaScript">
  9. function enb() {
  10. document.form1.send.disabled=true;
  11. }
  12. </SCRIPT>
  13. </head>
  14. <body 
  15. <%
  16. IF test=1 THEN
  17. %>
  18. onLoad="enb()"
  19. <%
  20. ELSE
  21. %>
  22.  
  23. <%
  24. END IF
  25. %>
  26. >
  27.  
  28. <form name="form1" id="form1" action="test.asp?action=called" method="GET">
  29.  
  30. <input type="button" name="send" id="send" value="send" />
  31.  
  32. </form>
  33.  
  34. </body>
  35. </html>
Oct 6 '08 #2
jhardman
3,406 Expert 2GB
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
Oct 6 '08 #3
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
Oct 7 '08 #4
jhardman
3,406 Expert 2GB
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
Oct 7 '08 #5
DrBunchman
979 Expert 512MB
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
Oct 7 '08 #6
jhardman
3,406 Expert 2GB
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
Oct 8 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Krishna | last post by:
Hi all, Can i call my javascript functions from the web controls.Any appropriate site which will be tell more on this will be helpfull. Regards.., Krishna
6
by: szabelin | last post by:
Hello, I am trying to call a function inside the javascript block from asp.net during the postback (NOT button's OnClick event handler though). The javascript function creates new popup window. I...
1
by: Markusek Peter | last post by:
How can I call JavaScript function within <TABLE> tags. I've got <table width="here should be return value from js script"> Thank you.
4
by: Martin Feuersteiner | last post by:
Dear Group I'm using VB to write an aspnet application. I would like to call a javascript function from within a VB Sub or VB Function, is it possible? My code is something like this: VB...
1
by: lwhitb1 | last post by:
I have been trying to load a javascript function from the body onload html tag, but I only want the function to load the first time the page is loaded: I have investigated but haven't found...
0
by: kike | last post by:
I want to call a javascript function WITH parameters function from c# code; I already did this: ..... StartDate.Attributes.Add("onTextChange","DateGreaterThan(" + StartDate.Value + "," +...
2
by: moralbarometer | last post by:
Hallo, I intend to have an html file generated with xsl. i want to have this line below in the html file. <a id="1" href="#" onclick="makeRequest('VALUE INSERTED USING XSL FROM XML')" test</a>...
0
by: ajitgoel | last post by:
Hi; We have a Javascript function which I have been tasked to move to a CSharp class. This javascript function uses Regular expression extensively. This function has a string input parameter and...
1
by: Larry | last post by:
Anyone have an example of a webuser control with a checkbox that passes information to a JavaScript function on the same page? on the page I have a checkbox and a textbox (both are server...
1
by: archcool | last post by:
hi iam new to php and i need help in my php file i have written php code and as well javascript code.the php code displays a form and i need to validate the fields present in the form calling a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.