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

    Question dropdown menu quiz

    hi all, I am very new to Javascript and trying to create a javascript quiz which students are answering them by choosing the answers from a dropdown menu, the dropdown menu are created by arrays, so they have common name like QS0, QS1...and so on.

    When I tried to submit the answers to a function for checking, I could not get the values over.I have been successful was a text box contect, but could not be done so with a drop menu.

    below are the sample code i am working on now before putting in the actual questions.

    ***

    the code works when i make the contect inside the function to read each of the dropdown menu sepearte, but I am trying to make it into an array so I can change the number of questions when required.

    many thanks


    <html>
    <head>
    <script type="text/javascript">
    function put()
    {
    for (i=0;i<2;i++)
    {
    txt=eval("document.forms[0].myList" + i + ".options[document.forms[0].myList" + i +.selectedIndex].text")
    document.forms[0].answer" + i +".value=txt"
    }

    }

    </script>
    </head>

    <body>
    <form>
    Question 1:
    <br /><br />
    <select name="myList0">
    <option value = "1">Answer A</option>
    <option value = "2">Answer B</option>
    <option value = "3">Answer C</option>
    </select>
    <br /><br />
    <select name="myList1">
    <option value = "4">Answer 0</option>
    <option value = "5">Answer 1</option>
    <option value = "6">Answer 2</option>
    </select>

    <br /><br />
    Your answer 1 is: <input type="text" name="answer0" size="20">
    <br /><br />
    Your Answer 2 is: <input type="text" name="answer1" size="20">
    <br /><br />
    <input type="button" name="button1"
    value="Display answers"
    onClick="put()">

    </form>
    </body>

    </html>
    Last edited by lmk; 03-03-2005 at 11:47 PM.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You may want to consider this instead of reinventing the wheel:
    www.klproductions.com/klquiz.html
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"

  • #3
    lmk
    lmk is offline
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    thank you for your help, but actually current design (not a very gd coding) is having a passage paragraph randomise (I have successed in this) and use a dropdown menu to allow student to choose the correct order of the paragraph.

    the problem lies in it now is that I can't pass the dropdown menu (which was created in array mehtod to the function for checking.

    my first post where the section was highlighted in red is the part I believe I am having problem with.

    thx

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here is a little demo for you that I threw together.
    http://webdeveloper.klproductions.co...tquizdemo.html
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"


  •  

    Posting Permissions

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