Warning: include(/home3/agurchan/public_html/theonlytutorials/wp-content/plugins/wp-super-cache/wp-cache-base.php): failed to open stream: No such file or directory in /home/agurchan/public_html/theonlytutorials/wp-content/plugins/wp-super-cache/wp-cache.php on line 65

Warning: include(): Failed opening '/home3/agurchan/public_html/theonlytutorials/wp-content/plugins/wp-super-cache/wp-cache-base.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/agurchan/public_html/theonlytutorials/wp-content/plugins/wp-super-cache/wp-cache.php on line 65

Warning: include_once(/home3/agurchan/public_html/theonlytutorials/wp-content/plugins/wp-super-cache/ossdl-cdn.php): failed to open stream: No such file or directory in /home/agurchan/public_html/theonlytutorials/wp-content/plugins/wp-super-cache/wp-cache.php on line 82

Warning: include_once(): Failed opening '/home3/agurchan/public_html/theonlytutorials/wp-content/plugins/wp-super-cache/ossdl-cdn.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/agurchan/public_html/theonlytutorials/wp-content/plugins/wp-super-cache/wp-cache.php on line 82
Simple onChange Redirect JavaScript select tag - TheOnlyTutorials.com

Simple onChange Redirect JavaScript select tag

Are you looking for a very simple JavaScript that can redirect to an URL onChange of the Dropdown box?

Here is the code which is ready to use on any of your project.

1.  JavaScript:


<script type="text/javascript">
function gotopage(selval){
var value = selval.options[selval.selectedIndex].value;
window.location.href=value;
}
</script>

2. Here is the HTML Part:


<select onchange="gotopage(this)">
<option value="">Select</option>
<option value="http://www.google.com">Google</option>
<option value="http://www.yahoo.com">Yahoo</option>
<option value="http://www.msn.com">MSN</option>
</select>

For your Convenience here is the Entire Javascript Redirect Example:


<html>
<head>
<script type="text/javascript">
function gotopage(selval){
var value = selval.options[selval.selectedIndex].value;
window.location.href=value;
}
</script>
</head>
<body>
<h3>Onchange Redirect Script</h3>
<select onchange="gotopage(this)">
<option value="">Select</option>
<option value="http://www.google.com">Google</option>
<option value="http://www.yahoo.com">Yahoo</option>
<option value="http://www.msn.com">MSN</option>
</select>
</body>
</html>

Leave a Reply