Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    javascript onchange method

    Hello,
    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;
    }

    </script>

    <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...

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Code:
    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.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •