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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Faking a submit button

Status
Not open for further replies.

Whiteybags

Technical User
May 18, 2004
18
IE
Hi,
I want to fake a submit button. I have two pages. I want to have a submit button on the first page that when clicked goes to the second page. The submit button doesn't actually have to do anything except go to the next page. Can I do that?
<input type="button" value="Submit" name="Submit" onclick="page2.htm">
Thanks.
 
Jeff: Correct me if I am wrong but wouldn't it be better to use:

<form method="get" action="page2.htm">
<input type="button" value="Submit" name="b1" />
</form>

that way it would work for users with Javascript turned off.

Also I believe it is unwise to use "Submit" as a button name because it is also a Javascript keyword.

Clive
 
Using "Submit" as a name should cause no issues because of the case-sensitive nature of JavaScript. If you named the button "submit", you would have trouble calling the form's "submit" method, but with it named "Submit", you should still be able to call the "submit" method.

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Clive,

There are so many ways to do the task. I wouldn't use a form button in the same way personally... but without getting into a long discussion about alternatives with the OP, it made more sense to answer their question directly and build on the solution they were working with (using an onclick which just needed a bit of tweaking).

I think Dan covered the reasoning on using Submit rather than submit on this one - but again... I was merely building on the OP's original code (so as not to confuse).

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top