Click to See Complete Forum and Search --> : Posting without Submitting
richy
Nov 14th, 2000, 10:27 AM
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.
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
richy
Nov 15th, 2000, 04:49 AM
thanks alot PWNettle, thats exactly what I needed.
richy
Nov 15th, 2000, 06:00 AM
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!
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
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.