View Full Version : javascript onchange method

08-23-2010, 05:17 AM
i wrote this code, But is not working, i want to use onChange event and redirect user into a url accordingly. this is my code;

<script type="text/javascript">

function goto()
var URL = document.frmsort.optsort.options[document.optsort.optsort.selectedIndex].value;
window.location.href = URL;


<form id="frmsort" name="frmsort" action="http://localhost/APP/category.php" method="post">
<select name="urls" onChange="goto()">
<option value="http://localhost/APP/category.php?sub=1">-- choose option --</option>
<option value="http://localhost/APP/category.php?sub=1&sort=1">OP1</option>
<option value="http://localhost/APP/category.php?sub=1&sort=2">OP2</option>
</select> </form>

I really appreciate your help...
thank you...

Philip M
08-23-2010, 07:46 AM
var URL = document.frmsort.urls.value;
window.location.href = URL;

All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.