View Full Version : submitting a form

04-04-2003, 08:34 PM
I have a form with text boxes. Also instead of a submit button, I have an image. Once the user fills out the form, if he hits the enter key the form should submit. But since I am using an image nothing is happening. How can I write a javascript so when the user hits the enter key the form automatically gets submited? Here is what I wrote which is not working:

<form name="newcustomer" method="post" action="http://www.hotmail.com">

<input type="texbox" size="30" name="fname"><br>
<input type="textbox" size="30" name="lname"><br>
<A HREF="javascript:document.newcustomer.submit()"><img src="images/save.gif" border="0"></a>

04-04-2003, 09:14 PM
<input>'s of type image act just like <input>'s of type submit, meaning they both act as a submit button

<input type="image" src="images/save.gif" />


04-04-2003, 09:45 PM
Is that consistent behavior with the other browsers out there, or is IE diverging from the standard?

04-04-2003, 10:08 PM
No, it's been that way since HTML 3.2 (http://www.w3.org/TR/REC-html32#input) at least.

Ooh, look! It was in HTML 2 (http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.1.2.5)!!

I'd say it's consistent :D

04-04-2003, 10:10 PM
Not Tim Berners-Lee's original version? Bad - there's probably lots of browsers out there who only knows his version.</irony>

04-04-2003, 10:29 PM
Thanks it worked :)

It doesnt work in Netscape 4.7. It works in NN6.x