Linking to other web pages with forms

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fredrik anderson
    New Member
    • Oct 2006
    • 4

    Linking to other web pages with forms

    I am relatively new to HTML, and want to do something that I think should be simple without getting bogged down with other programs like PHP or JavaScript or ASP or anything.

    I want to create a website with drop down lists, such as this:
    [1]
    DOG
    CAT
    BUG
    ANT
    [2]
    RED
    BLUE
    GREEN
    YELLOW

    If the user picks DOG and GREEN, I want to user to be directed to website ...xxx/DOGGREEN.HTML by clicking the button.

    I have searched and searched, but I cannot find the answer anywhere without being faced with learning a new program.

    Any help greatly appreciated.
  • fredrik anderson
    New Member
    • Oct 2006
    • 4

    #2
    Ideally, when the user selects options from the two drop down lists (one is called "animal", the other "color"), the file recognizes that DOG is now the animal, and GREEN is now the color.

    So I thought of something like this:
    onClick= "window.open('h ttp://www.yyy.com/data/'+animal+color+ '.html')"

    That would pull up:
    www.yyy.com/data/DOGGREEN.html'

    But it didn't work that way.

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by fredrik anderson
      Ideally, when the user selects options from the two drop down lists (one is called "animal", the other "color"), the file recognizes that DOG is now the animal, and GREEN is now the color.

      So I thought of something like this:
      onClick= "window.open('h ttp://www.yyy.com/data/'+animal+color+ '.html')"

      That would pull up:
      www.yyy.com/data/DOGGREEN.html'

      But it didn't work that way.
      you do not just want to say animal
      but animal.options[animal.options. selectedIndex].value

      Comment

      • fredrik anderson
        New Member
        • Oct 2006
        • 4

        #4
        Thanks a million. I think I'm getting closer, but still not there yet.

        These are my forms

        <select name=Animal id="option1" size=1>
        <option>Dog
        <option>Cat
        <option>Bird
        </select>

        <select name=Color id="option2" size=1>
        <option>Green
        <option>Red
        <option>Yello w
        <option>Blue
        </select>

        I stuck the "id" values in there in case that was the identifier, but I'm not sure.

        Based on your recommendation, my onclick is:

        onClick= "window.open('h ttp://www.yyy.com/data/' + Animal.options[Animal.options. selectedIndex].value + Color.options[Color.options.s electedIndex].value + '.html')"

        Unfortunately, I still don't get the reply. The output is:

        http://www.yyy.com/data/.html

        Any further insight greatly appreciated.

        Comment

        • fredrik anderson
          New Member
          • Oct 2006
          • 4

          #5
          Follow-up : do I need javascript for this? I've never used it.

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by fredrik anderson
            Follow-up : do I need javascript for this? I've never used it.
            Yes you need javascript and you are already using it. You did not specify the value attribute for your options

            <OPTION value = "dog">dog</OPTION>

            if you are going to be doing options.value, you need to set the values first.

            Sorry for the delay. I've just been having network problems.

            Comment

            Working...