SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help With Script

    This script should be simple ... I am trying to get the page to change based on selection. It always goes to Yahoo though, never Google (if I select the second.) Any help is appreciated!!!!!!!

    <script language="javascript">
    function DoTheCheck() {
    if (document.form1.audience.options[0].text = "All Community")
    {
    self.location = "http://www.yahoo.com"
    }
    else if(document.form1.audience.options[1].text = "Men")
    {
    self.location = "http://www.google.com"
    }
    else
    {
    alert("Getting Close!!!")
    }

    }
    </script>
    <form name="form1">
    <select name="audience">
    <option value=0>All Community</option>
    <option value=1>Men</option>
    <option value=3>Women</option>
    <option value=4>Cooks</option>
    <option value=5>Eaters</option>
    <option value=6>Youth (Ages 14-20)</option>
    <option value=7>Young Adult (Ages 18-30)</option>
    <option value=8>Family</option>
    <option value=9>Ages 50 and Better</option>
    <option value=>Firemen</option> </select></form>
    <input type="submit" onClick="DoTheCheck()">

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please use &#91;code&#93;…&#91;/code&#93; around code samples to make them readable.

    In JavaScript, a single '=' is the assignment operator.
    The equality comparison operator is '=='.
    Birnam wood is come to Dunsinane

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks ... that was dumb of me. also i shouldn't have referenced the options array in my function.


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
  •