SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    East Side
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Form object problem...

    Hi all -

    I am attempting to give the user a drop down menu box and have them select one of three options. Then click on the continue image and be sent to a certain page depending on what choice they have made... Here is my code:

    with "former" being the name of the form and "word" being the name of the drop down menu...

    <script>
    function getit() {
    if ((document.former.word.value = "test1")){window.location = "index.html"}
    else if ((document.former.word.value = "test2")) {window.location = "index1.html"}
    else if ((document.former.word.value = "test3")) {window.location = "index2.html"}

    }
    </script>


    I can only get it to send the user to index.html... any suggestions??? Thanks!

  2. #2
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It looks like you are missing semicolons... have a look at www.javascriptsource.com -- there is a script there that does exactly what you want.
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  3. #3
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    actually, i don't think the problem is semi-colons, the problem is your evalutation statements. insetead of:

    if ((document.former.word.value = "test1")){window.location = "index.html"}

    you need to use 2 "=" signs, like this:

    if (document.former.word.value == "test1"){window.location = "index.html"}

    try that.

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    East Side
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok - I guess the problem was not in the JS but actually part of the form object. Apparently I needed to add values to each of the menu options for it to work properly... all good now - thanks...

  5. #5
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    make sure you still fix the evaluation statements in your JS or it still won't work the way you want it to.

  6. #6
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    East Side
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    actually I put those extra "="'s into the statements and it didn't work at all... the word "test1" etc. wasn't exatly a word the the user would enter but rather one of the options on the menu. So instead of referencing "test 1" as the value, I now actually entered a value (in the code) of 1... confusing but it works properly now! thanks!

  7. #7
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Hundley
    actually I put those extra "="'s into the statements and it didn't work at all... the word "test1" etc. wasn't exatly a word the the user would enter but rather one of the options on the menu. So instead of referencing "test 1" as the value, I now actually entered a value (in the code) of 1... confusing but it works properly now! thanks!
    Thats strange because 1 = sign applys the left side to the right side. It doesn't (or shouldn't) evaluate anything
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  8. #8
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    East Side
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This chunck of code works in IE but not in Netscape...anyone wanna guess why!!?!?!?! thanks...


    <script>
    function getit() {
    if ((document.former.word.value == "1")) {window.location = "reportlist2a.html"}
    else if ((document.former.word.value == "2")) {window.location = "reportlist2b.html"}
    else if ((document.former.word.value == "3")) {window.location = "reportlist2c.html"}

    }
    </script>

  9. #9
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    East Side
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok - messed with this code a little more... the problem, I believe, has something to do with the form object. I think this because when I change the list/menu form to a text field everything works properly in both IE and NS... what do you think?


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
  •