Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2012
    Thanked 0 Times in 0 Posts

    Dynamic Selection Boxes with Answer not working.

    Hello, I am a newbie and I am wondering why this script does not work on my site (wordpress). Your assistance would be greatly appreciated, thanks! Kim

    <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;

    <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 id="dyrs">
    <option value="_">Years</option>
    <option value="1">3 years DA</option>
    <option value="2">4 years DA</option>

    <button onclick="showSelections()">Show Selections</button>

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Thanked 4,743 Times in 4,705 Posts
    Works fine for me. If it doesn't work in your WordPress page, it's possible you have a JavaScript conflict with other stuff on the page.

    Maybe give us the URL of your page?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


    Tags for this Thread

    Posting Permissions

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