...

View Full Version : submitting a form



chelvis
04-04-2003, 07: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>

beetle
04-04-2003, 08: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" />

http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/input_image.asp

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

beetle
04-04-2003, 09: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

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

chelvis
04-04-2003, 09:29 PM
Thanks it worked :)

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum