View Full Version : what is the script to create a button and...

07-15-2005, 11:48 PM
I am trying to create a button (onClick) that will get to a specified page. Can anyone help?



07-16-2005, 09:07 AM
<button onclick="window.location.href='newpage.htm';">Go to newpage.htm</button>
If you're willing to take a little time over it, you'll be better off using a link with a outset border-style and a grey background to make it LOOK like a button, thus making it work in non-JS browsers.

<a href="newpage.htm" style="text-decoration: none; border-style: outset; background-color: grey; border-color: grey; border-width: 3px; color: black;" onclick="this.style.borderStyle='inset';">Go to newpage.htm</a>
Or, you can use a form with no inputs:

<form action="newpage.htm" method="post">
<input type="submit" value="Go to newpage.htm"/>

Tweak as required.

07-16-2005, 02:22 PM
say if I would like to allow guests to enter/select on which state they're in in a text field, then (as they click on a button) I would like the site to direct accordingly.... what would be the steps for this type of action....???



07-16-2005, 02:32 PM
If you have a server-side language installed, that would be better; however, if you don't, you'd use Javascript like so:

<select id="state">
<option value="alabama.htm">Alabama</option>
<option value="michigan.htm">Michigan</option>
<!-- ... and so on ... -->
<button onclick="window.location.href=document.getElementById('state').value;">Go</button>
If Alabama were selected, the user would be sent to alabama.htm; if Michigan were selected, the user would be sent to michigan.htm, and so on.