Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript and forms

Status
Not open for further replies.

tyrannus

MIS
Apr 6, 2006
115
US
I have a form that has many text fields and if I add in a simple submit button, if the enter key is pressed while in a field it will submit the form. This I do not want. Instead I want to use onclick to call a javascript function that will submit when clicked only, the enter key does nothing.

I found this script but it does not work:

javascript:
<script language="JavaScript">

function submitform(form)
{
document.myform.submit();
}
</script>
myform is the name of the form.

then for the button I have this:

<input type="button" onClick="return submitform()" name="submit" value="Send">

I need for this to work in both IE and Firefox. I just cannot seem to get it to work.
 
Don't name your button submit, try changing it to something like mySubmit. I don't know that it will fix the problem but at least it's dodging one potential problem:
Code:
<input type="button" onClick="return submitform()" name="[!]mySubmit[/!]" value="Send">

-kaht

Looking for a puppy?

silky-icon-left.gif
[small]Silky Terriers are small, relatively odorless dogs that shed no fur and make great indoor pets.[/small]
silky-icon-right.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top