SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Feb 2000
    Location
    Madawaska, ME, USA
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have a form that has a SELECT object. I would like to go to a URL dependent on the choice the user makes.

    Something like this:

    <select size="1" name="D1" onchange="window.location='http://localhost/test.htm?Choice=this.value'">
    <option value="red">red</option>
    <option value="blue">blue</option>
    </select>

    What I would like to see is "http://localhost/test.htm?Choice=blue" sent to the browser.
    My syntax is wrong, or something. Can someone help me?

  2. #2
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi ryanc,

    Have to run off to eat.

    <select....onChange='doSel(this)'>

    function doSel(selObj)
    {
    for (i=0; i< selObj.length; i++)
    if (selObj.options[i].selected)
    location.href='http://localhost/test.htm?choice=' + selObj.options[i].value;
    }


    See the 'Select & Go Menus' script/tutorial at my site for an explanation fo the doSel() function.

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  3. #3
    SitePoint Member
    Join Date
    Sep 2000
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I ran a few test and with using your code I developed this, and it works.

    <select size="1" name="D1" onchange="window.location=document.all.D1.value">
    <option value="http://www.go.com">Go</option>
    <option value="http://www.sitepoint.com">SitePoint</option>
    </select>

  4. #4
    SitePoint Member
    Join Date
    Feb 2000
    Location
    Madawaska, ME, USA
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Gentlemen,

    Within your responses you have demonstrated the exact reason I prefer this forum to the News Groups. When asking a question in the News Groups, the answer is usually a few lines, but the people responding would rather go into a 10 page thesis as to why the person asking the question should have referred to the perldocs, FAQs, etc. The whole purpose of using a forum is to tap the exact people who know the answer to your question.

    Both your solutions were exactly what I was looking for.

    Thank you.

  5. #5
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi ryanc,

    You're welcome.
    But...
    You shouldn't be too hard on the newsgroup people (I spend time there occasionally After all, what they say about checking the faqs and searching are things everyone should attempt first. In forums, a lot of responses are of the "search the forum" and 'follow this link' type. I use those myself once I have enough responses on the forum.
    Other good sources (for javascript newbies) are:
    1) http://htmlgoodies.earthweb.com --> the javascript primer
    2) a decent, but easy to understand, book --> SAM's Javascript in 24 hours.



    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still


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
  •