/    Sign up×
Community /Pin to ProfileBookmark

input type=button linking to a URL?

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. ?

to post a comment
HTML

10 Comments(s)

Copy linkTweet thisAlerts:
@mponsoAug 06.2005 — 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. ?[/QUOTE]


you can do:

< input .... onclick="window.location='http://www.w3schools.com'">

or in new window:

<input ..... onclick="window.open('http://www.w3schools.com')">
Copy linkTweet thisAlerts:
@NogDogAug 06.2005 — Or, if you'd like it to work even for users who do not have JavaScript enabled:
[code=html]
<form action="http://www.yoursite.com/bylaws.html" method="post">
<input type="submit" name="BYLAWS" value="BYLAWS"></form>
[/code]
Copy linkTweet thisAlerts:
@RealTycheauthorAug 06.2005 — 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?
Copy linkTweet thisAlerts:
@NogDogAug 06.2005 — ...

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

type="button" name="BYLAWS" value="BYLAWS"></form>

Any ideas?[/QUOTE]

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.)
Copy linkTweet thisAlerts:
@RealTycheauthorAug 06.2005 — 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.

?
Copy linkTweet thisAlerts:
@RealTycheauthorAug 06.2005 — 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
Copy linkTweet thisAlerts:
@FireBallAug 06.2005 — <form action="http://www.the-packrat.com/bylaws.html" method="post"> <input

type="button" name="BYLAWS" value="BYLAWS"></form>[/QUOTE]

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>[/QUOTE]

dont forget to place a name="framename" in the frames bracket also or it will not work for ya.
Copy linkTweet thisAlerts:
@RealTycheauthorAug 08.2005 — Thankee Fireball, worked wonderfully. ?
Copy linkTweet thisAlerts:
@KravvitzAug 08.2005 — 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.

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


Note: The target attribute is not allowed in the Strict variants of HTML 4.01 and XHTML 1.0.
Copy linkTweet thisAlerts:
@VMKensingtonMay 06.2018 — @NogDog#413740 You saved someones Day with a 13yr old post.... Thank you ?
×

Success!

Help @RealTyche spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...