/    Sign up×
Community /Pin to ProfileBookmark

Redirect buttons

Hello,

I’m hoping this is an easy one for most of you :o)

How do I make two buttons to do the following?

button 1: [Agree] when clicked goes to designated webpage
button 2: [Disagree] when clicked goes to a different designated webpage

Thanks,
MonaE

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@bgreel00Nov 29.2005 — in the input tags for the buttons use the onClick attribute to set the URL ie

<html>

<head>

<script language="javascript">

function goURL1() {

window.document.location.href = 'http://url1';

}

function goURL2() {

window.document.location.href = 'http://url2';

}

</script>

</head>

<body>

<input type="button" value="Agree" onClick="goURL1()" />

<input type="button" value="Disagree" onClick="goURL2()" />

</body>

</html>

hope this helps.
Copy linkTweet thisAlerts:
@konithomimoNov 29.2005 — <i>
</i>&lt;html&gt;
&lt;head&gt;
&lt;script type="text/javascript"&gt;
function goURL1(num)
{
if (num == 1) window.location = 'http://url1';
else window.location = 'http://url2';
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;input type="button" value="Agree" onClick="goURL(1)" /&gt;
&lt;input type="button" value="Disagree" onClick="goURL(2)" /&gt;
&lt;/body&gt;
&lt;/html&gt;


OR
<i>
</i>&lt;html&gt;
&lt;body&gt;
&lt;input type="button" value="Agree" onClick="window.location='http://url1';"&gt;
&lt;input type="button" value="Disagree" onClick="window.location='http://url2';"&gt;
&lt;/body&gt;
&lt;/html&gt;
×

Success!

Help @MonaE 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 5.14,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...