473,378 Members | 1,467 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,378 software developers and data experts.

Submission of a form using javascript....

108 100+
I want to submit my form using javascript but the prob I am facing here is when using this method,the form is being submitted irrespective of the return value of onsubmit .My script is .....
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <script type="text/javascript">
  3. function chk(){
  4.  
  5.     document.formname.submit();
  6. }
  7. </script>
  8. <body>
  9. <form name="formname" action="from.html" onsubmit="return false" method="get">
  10. <input type="text" name="firstbox">
  11.  
  12. <button onclick="chk()">Submit</button>
  13. </form>
  14. </body>
  15. </html>
  16.  
Any help willl be deeply appreciated...Thanks
Dec 14 '09 #1
4 1966
gits
5,390 Expert Mod 4TB
that is correct ... what do you want to achieve?

kind regards
Dec 14 '09 #2
phpuser123
108 100+
the prob I am facing is that although the onsubmit has a return value of false,it is being submitted.When I am using <input type="submit" value="submit"> to submit the form,the form is nt submitted since the onsubmit holds a value of false..Why this difference? And what cn I do so that the form is not submitted with the javascript?
Dec 15 '09 #3
gits
5,390 Expert Mod 4TB
just don't call the submit()-method when the form shouldn't be submitted ... a simple if-else would do the job in your chk()-function

kind regards
Dec 15 '09 #4
acoder
16,027 Expert Mod 8TB
...or avoid the use of chk() and make a call to your validation function onsubmit:
Expand|Select|Wrap|Line Numbers
  1. onsubmit="return validate()"
Also note that button by default is a submit button. Perhaps you meant to use an input button (input type="button"). Alternatively, set the button type to "button".

One more thing: the submit is prevented when the user clicks on the submit button, not when the form is submitted using JavaScript via submit().
Dec 21 '09 #5

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

Similar topics

2
by: Logical | last post by:
I have a form which houses basic inputs, as well as a few multiple select forms. I need to parse all the 'values' which are in this multiple select form (it gets manipulated dynamically client...
6
by: Charles Banas | last post by:
weird subject - i hope more than just one curious regular will hear me out. :) ok, i've got a bit of a big problem, and i need answers as soon as possible. i know this forum is meant for web...
3
by: Chris Smith | last post by:
Good morning, Is there a good way to use JavaScript to send a form submission, but get back the response as a string, rather than loading it into a page? I could write the code to send the...
6
by: nick4soup | last post by:
I have read the CGI FAQ 'How can I avoid users hitting "submit" twice' (on http://www.htmlhelp.org/faq/cgifaq.3.html#19 ) which essentially says you have to detect it at the server, using a...
6
by: brettev | last post by:
World, I work at a university where the professors have a system to input grades for assignments and calculate final grades, which is output to an excel file. they are then required to get on a...
4
by: kschneider | last post by:
Assume there's a form with it's action attribute all set to post to a URL, but without a submit control. Form submission is done via a link and I want to prevent the classic "double submit"....
6
by: Oleg Konovalov | last post by:
Hi, I have a Java/JavaScript GUI application where I perform a lot of long DB operations , which takes 5-60 secs to perform. Sometimes user double-clicks the button or just gets impatient and...
1
by: rn5arn5a | last post by:
Nowadays, most websites make use of CAPTCHA to prevent automated Form submission. Can someone please give me examples of how automated Form submission can be achieved? It's not that I intend to...
2
by: Rahina | last post by:
I am working in Dreamweaver 8, and I have created a simple form: http://www.realmofmystery.com/app.html This is a free website I am doing for some friends, so nothing fancy. And, I learned web...
5
by: dmorand | last post by:
I'm having a strange issue with a form I'm developing. I'm saving some values to hidden fields when a user clicks a button. I setup a function which gets ran on submission of the form, but I also...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.