Results 1 to 5 of 5

Thread: Posting without Submitting

  1. #1

    Thread Starter
    Hyperactive Member richy's Avatar
    Join Date
    Jan 1999
    Location
    Liverpool, England
    Posts
    353
    Is there anyway of Submitting a form in JavaScript without having to press the button. The reason that I want to do this is if enter is pressed in a field, then the form should automatically Submit itself. I've done all the testing for the Enter key and that is working fine, but the problem is the actual submit.

  2. #2
    Guest
    Give your form a name and use something like:

    frmTest.submit()

    For example, you can do this with a link like so:

    <A HREF="doesntmatter.html" onClick="frmTest.submit(); return false;">Clicking here causes form submission, not link following</A>


    Paul

  3. #3

    Thread Starter
    Hyperactive Member richy's Avatar
    Join Date
    Jan 1999
    Location
    Liverpool, England
    Posts
    353
    thanks alot PWNettle, thats exactly what I needed.

  4. #4

    Thread Starter
    Hyperactive Member richy's Avatar
    Join Date
    Jan 1999
    Location
    Liverpool, England
    Posts
    353
    except for some reason it doesn't work. Instead I get the error of Object doesn't support this property or method.

    I have the following cut down code:


    In the JavaScript section:

    function textchange(keyasc)
    {
    if(keyasc==13)
    {
    myform.Submit();
    }
    }
    </script>

    In the HTML:

    <form name="myform">
    <input type="text" name="textfield" onkeypress="textchange(event.KeyCode);">
    <input type="submit name="Submit" value="Search" onClick="return parent.mainFrame.findInPage(this.form.textfield.value);">
    </form>


    I know when I click the Submit, that works and I also know that the keyasc value is returning the correct values, but I can't get the form to Submit...Please Help!


  5. #5
    Guest
    The only thing I can think of is that the 'submit()' needs to be lowercase. JavaScript is case sensitive. Try '.submit()' rather than 'Submit()' and see if that works.

    Paul

Posting Permissions

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



Click Here to Expand Forum to Full Width