Radio Button Chooses New URL

[Total: 0    Average: 0/5]

This shows how to use a radio button selection to redirect the web browser.

Head Code:

<script>
function redirect(oform){
var href=null
for (var i=0;i<oform.rdoption.length;i++)
{ if (oform.rdoption[i].checked)
	  href=oform.rdoption[i].value
}
if (href !=null)
	document.location.href=href
return false
}

</script>

Body Code:

<form onsubmit='return redirect(this)'>
<input type='radio' name=rdoption value= '/'> JS-E Home Page
<input type='radio' name=rdoption value= '/example/'> JavaScript Page
<input type='radio' name=rdoption value ='/asp/'> ASP Page
<br>
<input type=submit>
</form>

Times Viewed: 3

Leave a Reply

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