Click to See Complete Forum and Search --> : input type=button linking to a URL?


RealTyche
08-05-2005, 06:49 PM
Hi hi everyone.
I've battered my poor HTML book to peices trying to find the answer to my dilemma, that being using an Input type=Button to act as a link to another URL, much as the <a href> tag does. So far, nothing I've tried has worked. Is there any way to do this?

The code I'm using is as follows:

<input type="button" name="BYLAWS" value="BYLAWS" onclick=??? This is where the url would go.>

Any advice would be GREATLY appreciated. :D

mponso
08-05-2005, 07:21 PM
Hi hi everyone.
I've battered my poor HTML book to peices trying to find the answer to my dilemma, that being using an Input type=Button to act as a link to another URL, much as the <a href> tag does. So far, nothing I've tried has worked. Is there any way to do this?

The code I'm using is as follows:

<input type="button" name="BYLAWS" value="BYLAWS" onclick=??? This is where the url would go.>

Any advice would be GREATLY appreciated. :D

you can do:
< input .... onclick="window.location='http://www.w3schools.com'">
or in new window:
<input ..... onclick="window.open('http://www.w3schools.com')">

NogDog
08-05-2005, 08:07 PM
Or, if you'd like it to work even for users who do not have JavaScript enabled:

<form action="http://www.yoursite.com/bylaws.html" method="post">
<input type="submit" name="BYLAWS" value="BYLAWS"></form>

RealTyche
08-05-2005, 08:44 PM
Unfortunately, niether of those worked. The button just sist there and does nothing, which leads me to suspect there's an error somewhere in my code itself that the browser doesn't know what do do with. :/

Here's both codes as I used them:
<input type="button" name="BYLAWS" value="BYLAWS" onclick=window.location='http://www.w3schools.com'" target="main">

and

<form action="http://www.the-packrat.com/bylaws.html" method="post"> <input
type="button" name="BYLAWS" value="BYLAWS"></form>

Any ideas?

NogDog
08-05-2005, 09:03 PM
...

<form action="http://www.the-packrat.com/bylaws.html" method="post"> <input
type="button" name="BYLAWS" value="BYLAWS"></form>

Any ideas?
Change the type="button" to type="submit". (I should have mentioned that explicitly in my post instead of just burying it inside the example code.)

RealTyche
08-05-2005, 10:23 PM
NogDog, I sincerely appreciate you taking all this time with me. I changed the type according to your instructions and it sort of worked...then button leaped heroically out to the web and crashed into this:

The requested method POST is not allowed for the URL /bylaws.html.

:(

RealTyche
08-05-2005, 10:38 PM
I got it..I changed method to 'link' and it worked like a jiffeh. Thanks....now how to I tell it not to pop up a new browser window but to pull the new page up in my main frame? LOL

FireBall
08-06-2005, 07:18 AM
<form action="http://www.the-packrat.com/bylaws.html" method="post"> <input
type="button" name="BYLAWS" value="BYLAWS"></form>
place a target tag in there like
<form action="http://www.the-packrat.com/bylaws.html" method="post"> <input
type="link" name="BYLAWS" value="BYLAWS" target="framename"></form>
dont forget to place a name="framename" in the frames bracket also or it will not work for ya.

RealTyche
08-07-2005, 10:53 PM
Thankee Fireball, worked wonderfully. :)

Kravvitz
08-08-2005, 01:18 PM
Ugh frames.

Anyway, there are only two allowed values for <form>'s method attribute: post and get, which is the default. So when you set it to "link" it was really using "get".

target is not an attribute of <input>; it's an attribute of <form>.

By removing the name attribute from the <input> the name/value pair won't be sent when the form is submitted.

<form action="http://www.the-packrat.com/bylaws.html" method="get"
target="framename"><input type="submit" value="BYLAWS"></form>

Note: The target attribute is not allowed in the Strict variants of HTML 4.01 and XHTML 1.0.