SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Mar 2005
    Location
    California, US
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    onChange submit new value to querystring.

    I have a drop down such as this:

    Code:
    <SELECT name="sectionid" class="InputWidth">
    <OPTION value="1">Section 1</OPTION>
    <OPTION value="2">Section 2</OPTION>
    <OPTION value="3">Section 3</OPTION>
    <OPTION value="4">Section 4</OPTION>
    </SELECT>
    current URL would be something like:
    Code:
    www.myURL.com/sections.php?section=2
    If you are on the page the option with value 2 will be already selected since section=2 in the url. How can I change the value of section int he url string to say section=1 if option value="1" was selected? Reloading the page isnt a problem.

    I have been seraching and just cant my answer. If anyone knows another thread that I am over looking or a tutorial I could get a link to I would be very grateful.
    Last edited by Gibberish; Mar 30, 2005 at 21:53.

  2. #2
    SitePoint Addict
    Join Date
    Mar 2005
    Location
    California, US
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok so what I am doing is this now:

    Code:
    <SELECT name="sectionid" class="InputWidth" onChange="window.open(sectionid.options[selectedIndex].value)">
    <OPTION value="sections.php?section=1">Section 1</OPTION>
    <OPTION value="sections.php?section=2">Section 2</OPTION>
    <OPTION value="sections.php?section=3">Section 3</OPTION>
    <OPTION value="sections.php?section=4">Section 4</OPTION>
    </SELECT>
    my problem here is it open a new window. Does anyone know the syntax for this same result but to load it into the current browser window and not a pop up?

    I have also tried this which does nothing:
    Code:
    <SELECT name="sectionid" class="InputWidth" onChange="window.location.href(sectionid.options[selectedIndex].value)">

  3. #3
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Parry Sound, ON
    Posts
    725
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:
    HTML Code:
    <select name="sectionid" class="InputWidth" onchange="window.location.href = sectionid.options[selectedIndex].value">


Bookmarks

Posting Permissions

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