TextButton Chooses New URL

[Total: 0    Average: 0/5]

This example sends the user to a new web page based upon the value of the button the user clicks upon.

Body Code:

<form name=exf1>
<input type="button" name="txtbutton" value="Page1" onClick="call_do()"> 
<input type="button" name="txtbutton" value="Page2" onClick="call_do()"> 
</form>
<script>
function call_do() { 
var myform=document.exf1;
var myval = myform.txtbutton.value;
if (myval=="Page1") 
  myform.action="http://www.js-examples.com/"; 
else if (myval="Page2") 
  myform.action="http://www.js-examples.com/consult"; 
myform.submit(); 
} 
</script>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *