Click to See Complete Forum and Search --> : How to make a button go somewhere?
briandunning
12-04-2003, 06:29 PM
This is a really easy one - but for some reason I've gone into brainlock and can't make it work.
I have an <input type="button"> inside of an irrelevant form. I just want to make that button navigate to "destination.html" when it's clicked, regardless of the form.
Someone please rescue me from brainlock...
fredmv
12-04-2003, 06:36 PM
<form action="http://www.google.com/" method="get">
<input type="submit" value="Google" />
</form>
briandunning
12-04-2003, 06:41 PM
Sorry, I guess I wasn't clear. The form is already being used for something else, so I have to make this button work without using the form.
I thought I always used to do it like this, but it's not working:
<input type="button" value="Go here" onClick="destination.html">
fredmv
12-04-2003, 06:49 PM
Oops. Sorry about that. The way I previously provided is the best way to use mainly because it works in browsers that don't support JavaScript — perhaps you could use another form for this and the other for the server-side script (in which is already making use of the action attribute)? If you don't want to do that, you could use the JavaScript way:<form action="#">
<input type="button" value="Google" onclick="location='http://www.google.com/';" />
</form>
briandunning
12-04-2003, 06:50 PM
That's the one I was looking for!!
Thanks - brain unlocked. :) :)
fredmv
12-04-2003, 06:56 PM
No problem. :D