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

onclick works in IE but not FireFox

Status
Not open for further replies.

vttech

Technical User
Jan 28, 2006
297
US
I created a button and use the onclick event to bring the use to another web page. This works in IE but not firefox. Why is this happening and how can I fix this??

Code:
<button onclick="location.href='facilities_form.php';">New</button>

the page can be viewed at


full code below

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] xml:lang="en-US" lang="en-US">
<head>
	<title>Form Lookup</title>
	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
body {font-family: verdana; font-size: 12px;}
form{margin: 100px auto 0;}
fieldset{width: 500px; margin: 0; padding: 0;}

p {float:left; margin: 0; padding: 0 10px;}
p input {width: 140px; margin: 0; padding: 0;}
p label {width: 75px; margin: 0; padding: 3px 0;}
p.submit {clear:left; margin: .5em 0;}
p.submit input, p.button button{width: 60px; }
p.button {margin: .5em 0;}


</style>
</head>
<body>
<form method="post" action="" >
<fieldset>
<p><label for="fname">First Name<br /></label><input type="text" name="fname" id="fname" /></p>
<p><label for="lname">Last Name<br /></label><input type="text" name="lname" id="lname" /></p>
<p><label for="form_id">Form ID<br /></label><input type="text" name="form_id" id="form_id" /></p>
<p class="submit"><input type="submit" name="submit" value="Find" /></p>
<p class="button"><button onclick="location.href='facilities_form.php';">New</button></p>
</fieldset>
</form>
</body>
</html>

Newbie in search of knowledge
 
I'm not 100% sure why <button> didn't work, but generally the use of <button> is not recommended.

The preferred method is <input type="button" for button use.

With that, this I tested in FF and works fine.

Code:
<p class="button"><input type="button" value="New" onclick="document.location='facilities_form.php'" /></p>

You may have to resize the button with CSS to make it look like the submit button.



[monkey][snake] <.
 
If you use my code and want it to look exactly like it did, use this code:

Code:
<p class="button"><input style=[!]"width:60px"[/!] type="button" value="New" onclick="document.location='facilities_form.php'" /></p>

[monkey][snake] <.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top