www.webdeveloper.com
Results 1 to 3 of 3

Thread: form.submit() behavior question

Hybrid View

  1. #1
    Join Date
    Dec 2008
    Location
    Pennsylvania
    Posts
    2

    form.submit() behavior question

    I just now found out the hard way that, at least in FF3, IE7 and Chrome (all on Windows), adding a submit input element to a form makes calling the submit() method in JavaScript not work. Why on earth would this be? I wanted to place the input so users with JS turned off would still have a way to submit the form. This is annoying and very puzzling.

  2. #2
    Join Date
    Feb 2003
    Location
    Michigan, USA
    Posts
    5,774
    It's not adding an input of type submit that breaks this behavior, it's that you named the INPUT "submit". When you have a DOM node reference to a FORM tag, its submit property is usually a function that submits the form. When you create a form field or button whose name is "submit", then you overwrite the default submit function of the FORM with a node reference to the form field or button. It's best to not name form fields "submit", "title", "elements" or "name", as those are important properties of the FORM object.

    Related reading: JavaScript, DOM, and the Humble FORM.

  3. #3
    Join Date
    Dec 2008
    Location
    Pennsylvania
    Posts
    2
    That's very clear. Thank you for explaining that.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles