Button.

admin

Administrator
Staff member
Hi, how do you make a button to go to another page. I want an 'I Accept' and 'I Decline' buttons..one to go to a page, the other a different page. how do you do this pls<!--content-->What you do is that in the onclcik event of the button add some javascript code,more likely a function,that performs redirectioning task when this button is clicked.<br />
Here is how this works.create 2 html input elements of type button<br />
<br />
<form name="form1" action=""><br />
<input type="button" value="I Accept" <br />
<input type="button" value="I Decline" onclick="redirectTo('no')"/><br/>onclick="redirectTo('yes')"/><br/><br />
</form><br />
<br />
Now you need to create javascript code.In the above html code when a onclick event is triggered by pressing the "I Accept" or "I Decline" buttons,the <br />
browser looks for function names redirectTo(param) in the javascript tags such as below.<br />
<script type="text/javascript"><br />
//define the function<br />
function redirectTo(parameter){<br />
//now we know that when I Accepts i pressed the function will have parameter value = yes and no otherwise,we'll put a condition to validate just that.<br />
if(parameter=="yes"){<br />
//now redirect to some page<br />
window.location.href=http://www.webdeveloper.com/forum/archive/index.php/"AgreementPage.html";<br />
}else if (parameter=="no"){//this is reduntant,only to show you the working..<br />
window.location.href=http://www.webdeveloper.com/forum/archive/index.php/"noAgreementPage.html";<br />
<br />
}<br />
}<br />
</script><br />
<br />
Hope this helps<!--content-->Thanks!<br />
Yes that is brilliant, thanks.<br />
gosh it's a lot more easier with normal text-links :)<!--content-->The absolute simplest answer in pure HTML is to use a pair of links with graphic buttons.<br />
<br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"tld.com/accept.htm"><img src="accept.gif" width="100" height="25" border="0"></a><br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"tld.com/decline.htm"><img src="decline.gif" width="100" height="25" border="0"></a><!--content-->Of course if you insist on using buttons,<br />
<br />
<form action="true.html"><br />
<div><input type="sumbit" name="I accept"></div><br />
</form><br />
<form action="false.html"><br />
<div><input type="sumbit" name="I decline"></div><br />
</form><!--content-->
 
Back
Top