Error Document.forms.myform.submit Is Not A Function
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the form.submit is not a function jquery validate company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions form$.get(0).submit() is not a function Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million document.forms is not a function programmers, just like you, helping each other. Join them; it only takes a minute: Sign up document.getElementById(“tweetform”).submit is not a function? up vote 21 down vote favorite 4 I'm using Firefox and I've been reading some forums form is not a function claiming this doesn't work in firefox but it has been working for me for the last few days but has stopped working and I can not figure out why. I make a AXAX POST Request using an IFrame. When I get the response I use this: function startLoad(){ $.get("update.php", function(data){ if(data==''){ startLoad(); } else{ document.getElementById("tweetform").submit(); } }); } However, from firebug, I get this: document.getElementById("tweetform").submit is not a function [Break on this error]
Cannot Read Property 'submit' Of Undefined
document.getElementById("tweetform").submit(); I know submit exists, but what is going on? javascript share|improve this question edited Dec 13 '14 at 21:58 AlexKM 1,49371627 asked Jul 8 '09 at 22:38 Abs 13.2k68208356 1 Does the element tweetform exist? Is it a form? –seth Jul 8 '09 at 22:41 Can you alert(document.getElementById("tweetform")) and check whether it returns a form? –Pradeep Jul 8 '09 at 22:44 Yes, tweetform exists and that alert returns: [object HTMLFormElement] –Abs Jul 8 '09 at 22:51 What does alert(document.getElementById("tweetform").submit) show? –Nick Lewis Jul 8 '09 at 22:57 Why are you using "document.getElementById" when you are using jQuery? Why not just use "$('#tweetform')"? –Chris Pietschmann Jul 9 '09 at 0:01 add a comment| 5 Answers 5 active oldest votes up vote 73 down vote accepted My guess would be that you have an element in the form that is called "submit" (possibly a
html, World Wide WebStoimen .submit() You want to submit the form by clicking on a link or some other element
Uncaught Typeerror: Document.getelementbyid Is Not A Function
on the page and this is a simple task. You form.submit not working know that by simply adding something like document.forms[‘the-form-name'].submit() this will work.
However you'd like to submit the form not only by clicking on that particular element, but also http://stackoverflow.com/questions/1100919/document-getelementbyidtweetform-submit-is-not-a-function by clicking on the Enter while the focus is on a input field, and this wont work! That's because you don't have a input type="submit". OK, first thing is to add a hidden input type="submit" - than by clicking both on the Enter keyboard button and on the link with http://www.stoimen.com/blog/2010/07/05/document-formsmyform-submit-is-not-a-function/ the onclick="document.blah.blah.blah" will submit the form. But this is not true! Than you'll receive the following message: document.forms['myform'].submit() is not a function Why? This isn't working, but ever line seems to be OK. The answer is - don't name the input type="submit" with the trivial - "submit". Just give it another name: CodeProjectRelated posts: Secure Forms with Zend Framework Detecting POST Requests in Zend Framework One Form - Multiple DB Records How to Setup Different Error Messages for Each Zend Form Element Validator How to Sanitize User Input in PHP? Post navigation ← PHP: preg_match Give Names to the Matches Zend Framework: Simple Acl Front Controller Plugin → 7 thoughts on “document.forms[‘myform'].sub- TypeError: document.getElementById(…).submit is not a functionDebugging, javascriptSometimes you try to validate HTML
Make sure if there isn't any sub-form added by mistake. Form within FormXHTML 1234Check case sensitivity of getElementbyId.JavaScript document.getElementById('FROM-ID').submit();1document.getElementById('FROM-ID').submit(); If your form is still not posting the form, check if any function is is not a returning false on submit event?JavaScript function validateForm() { /* some validation here */ return false; }123456function validateForm() {/*some validation here*/return false;}Share and EnjoyRelated Posts:Form auto-submission tips for jQueryAJAX style multiple images upload using HTML5, JSON and…Auto-import contacts into your getresponse campaign with…JavaScript job interview question - Find first non…Simple HTML5 geolocation plugin using jQuery So, what do you think ?Click here to cancel reply. Your Name Your Mail Your Website Message Search for: Follow @vikaskbhRecent Posts RequireJS example - loading desktop vs mobile javascript libraries and overriding functions How to style HTML form fields using CSS 3 linear-gradient() function? Javascript setTimeout() function jquery examples and chaining it with afterTime() plugin Flat UI - Simple HTML tabs without jQuery or any other library jQuery :contains() selector regex for matching text within elements@vikaskbhLinkedInGitHub © 2013-2014 vikaskbh.comnot a function If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 7 of 7 Thread: help on this error:document.forms[0].submit() is not a function Tweet Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 10-29-2003,12:34 PM #1 gklinux View Profile View Forum Posts Registered User Join Date Oct 2003 Posts 2 help on this error:document.forms[0].submit() is not a function hi, i'm working on a form which has an image button like this: basically there are multiple forms. my goSave function looks like this: function goSave(page) { document.forms[page].action= \"http://66.36.242.93/test123/testfiles/ccprform.php?pageno=2\"; document.forms[0].submit(); } i get a javascript error : document.froms[0].submit() is not a function. no error with document.forms[0].action , though. I'm doing these as an upgrade to an almost finished project, only this is stopping me. thanks in advance, gklinux Reply With Quote 10-29-2003,12:42 PM #2 suganya View Profile View Forum Posts Registered User Join Date Jun 2003 Location woodbury, MN Posts 48 try document.getElementById("formname").submit(); suganya Reply With Quote 10-29-2003,02:17 PM #3 gklinux View Profile View Forum Posts Registered User Join Date Oct 2003 Posts 2 syganya, the reason i'm trying something like this is because my script doesn't know a form name until a button is clicked. i want to be able to submit the form in which the button exists. why doesn't document.forms[0].submit() work? the solution you have suggested needs the name of the form hardcoded, which i don't want to do. i'm sure someone must have done this before! thanks, gklinux Reply With Quote 03-13-2007,04:46 PM #4 rjolly View Profile View Forum Posts Registered User Join Date Mar 2007 Posts 1 possible conflicting element name For anyone interested, "document.forms[0].submit();" will not work if any form elements are named "submit". Probably the original poster named the submit button "submit". Reply With Quote 03-14-2007,02:14 AM #5 Ultimater View Profile View Forum Posts