www.webdeveloper.com
Results 1 to 8 of 8

Thread: Dynamic Selection Box with Answers

  1. #1
    Join Date
    Jun 2012
    Location
    Vancouver Island, BC
    Posts
    4

    Dynamic Selection Box with Answers

    Hi there,

    I would like to do a dynamic selection box with answers and I do not know what the best route is to accomplish this. Wondering if anyone can point me to an example of the code that I could use as a template? Would very much appreciate your help as I am just starting to learn for my website. Thanks, Kim

    First box Options:
    1. small dog
    2. med dog
    3. lge dog

    Second box Options:
    a. 3 years DA
    b. 4 years DA

    Answer box:
    1+a selection = 29 HA
    2+a selection = 30 HA
    3+a selection = 31 HA
    1+b selection = 34 HA
    2+b selection = 36 HA
    3+b selection = 38 HA

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,259

    Lightbulb

    One, of many, possible solution...
    Code:
    <html>
    <head>
    <title> Untitled </title>
    <script type="text/javascript">
    var choice = {
      'a1':'29 HA', 'b1':'30 HA', 'c1':'31 HA',
      'a2':'34 HA', 'b2':'36 HA', 'c2':'38 HA'
    }
    
    function showSelections() {
      var dogSize = document.getElementById('dog').value;
      var dogYear = document.getElementById('dyrs').value;
      if ((dogSize == '_') || (dogYear == '_')) { alert('Missing choice'); return; }
      var pick = dogSize+dogYear;
      alert(choice[pick]);
    }
    </script>
    
    </head>
    <body>
    <select id="dog">
     <option value="_">Dog</option>
     <option value="a">Small Dog</option>
     <option value="b">Medium Dog</option>
     <option value="c">Large Dog</option>
    </select>
    
    <select id="dyrs">
     <option value="_">Years</option>
     <option value="1">3 years DA</option>
     <option value="2">4 years DA</option>
    </select>
    
    <button onclick="showSelections()">Show Selections</button>
    </body>
    </html>

  3. #3
    Join Date
    Jun 2012
    Location
    Vancouver Island, BC
    Posts
    4
    Hi, yes when I was looking into this I saw many directions but I didn't know what would work best with Wordpress. Thank you for your response I wasn't able to get the answer button to show the results though. Am I missing something?

    Cheers, Kim

  4. #4
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,259

    Question

    Quote Originally Posted by Kimmyf View Post
    Hi, yes when I was looking into this I saw many directions but I didn't know what would work best with Wordpress. Thank you for your response I wasn't able to get the answer button to show the results though. Am I missing something?

    Cheers, Kim
    I don't use Wordpress, so I'm not sure what the problem is.

    What 'answer button' are you talking about?

    What browser are you using that does not work for you
    and what kind of error are you getting with the supplied code.

    Are you using a different program? If yes, show the problem.

    Are you using a <!DOCTYPE ...> definition?

  5. #5
    Join Date
    Jun 2012
    Location
    Vancouver Island, BC
    Posts
    4
    Hi there,

    Thank you for the reply. The two drop down menus work and I am able to make the selections but when I press the show selection button to see the "answer", nothing happens. I have tried this on my Wordpress site using Chrome and also tried the code separately in dream weaver using IE. I have tried different doc types as well as using nothing.

  6. #6
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,259

    Question

    Quote Originally Posted by Kimmyf View Post
    Hi there,

    Thank you for the reply. The two drop down menus work and I am able to make the selections but when I press the show selection button to see the "answer", nothing happens. I have tried this on my Wordpress site using Chrome and also tried the code separately in dream weaver using IE. I have tried different doc types as well as using nothing.

    I'm not sure what your problem is at this time.
    I'm on an iMac at work and have tested post #2 using FF and Safari. I developed the script at home on my PC using FF and can not see an error on any tests performed.

    In order to solve your problem, you will either need to show the code you are using or find someone
    who knows the workings of 'Wordpress' or 'Dream Weaver' as I use neither and cannot be of help.

    Or post an active link to where the problem occurs so that we can see any error messages generated.

  7. #7
    Join Date
    Jun 2012
    Location
    Vancouver Island, BC
    Posts
    4
    Thanks Jmrker I got it to work! Appreciate all your help, you rock.

  8. #8
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,259
    Quote Originally Posted by Kimmyf View Post
    Thanks Jmrker I got it to work! Appreciate all your help, you rock.
    So what did you change or do differently?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles