Results 1 to 3 of 3

Thread: script for <select> value

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    447

    script for <select> value

    How do I make the selection go to the assigned value?
    Code:
    <select onchange="go();">
    <option value="/wheelofgod/tableformat.asp?page=1&sort=&keyword=jesus&text_data=yes&optAction=on">1</option>
    <option value="/wheelofgod/tableformat.asp?page=2&sort=&keyword=jesus&text_data=yes&optAction=on">2</option>
    <option value="/wheelofgod/tableformat.asp?page=3&sort=&keyword=jesus&text_data=yes&optAction=on">3</option>
    <option value="/wheelofgod/tableformat.asp?page=4&sort=&keyword=jesus&text_data=yes&optAction=on">4</option>
    <option </select>
    Compare bible texts (and other tools):
    TheWheelofGod

  2. #2
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: script for <select> value

    Try something like this:

    Code:
    function go()
    {
      var MySelect = document.getElementById('Select Elements ID Here');
      window.location.href = new String(MySelect.options[MySelect.selectedIndex].value);
    }
    ... or you can simply do this:

    Code:
    <select onchange="window.location.href = new String(this.options[this.selectedIndex].value);">
    <option value="/wheelofgod/tableformat.asp?page=1&sort=&keyword=jesus&text_data=yes&optAction=on">1</option>
    <option value="/wheelofgod/tableformat.asp?page=2&sort=&keyword=jesus&text_data=yes&optAction=on">2</option>
    <option value="/wheelofgod/tableformat.asp?page=3&sort=&keyword=jesus&text_data=yes&optAction=on">3</option>
    <option value="/wheelofgod/tableformat.asp?page=4&sort=&keyword=jesus&text_data=yes&optAction=on">4</option>
    </select>
    Either should work fine :-)

    Cheers,

    Ryan Jones
    My Blog.

    Ryan Jones.

  3. #3
    Member
    Join Date
    Dec 2006
    Location
    Malaysia
    Posts
    53

    Re: script for <select> value

    <select onchange="window.location.href = this.value">

Posting Permissions

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



Click Here to Expand Forum to Full Width