Could someone please take a look at my code? It's a simple quiz with one multiple choice question and one fill in the blank.

When the user clicks on 'submit' I tried to show some kind of response with correct/incorrect images next to the question. It works with the multiple choice question, but not with the fill in the blank. How can I get the fill in the blank question to work. It always shows the answer as being wrong. Thank you.

flag = true;
document.myquiz.a1c.style.backgroundImage="url('correct.gif')";
}
else{
document.myquiz.a1c.style.backgroundImage = "url('incorrect.gif')";
document.myquiz.a1c.value = " ANS: False. Position the head snugly against the top bar of the frame and then bring the foot board to the infant's feet.";
}

<B>1. When measuring height/length of a child who cannot securely stand, place the infant such that his or her feet are flat against the foot board.</B>
<label><INPUT TYPE=radio NAME=question0 VALUE="True" onClick="setAnswer(0,this.value)">True</label>
<label><INPUT TYPE=radio NAME=question0 VALUE="False" onClick="setAnswer(0,this.value)">False</label>

So what do you suggest I do to fix the problem?
Is there a different way of doing this?
Thank you.

lm111

09-14-2011, 02:05 PM

Does anyone have any suggestions please?? Thank you

Rowsdower!

09-14-2011, 02:23 PM

Instead of triggering the answer to log for question 2 with onchange just trigger it to log the answer for question 2 when "check answers" is run. You will still need to adjust your approach for logging that answer so that the three text inputs are assembled as an array which will mean that you can't use your current setAnswer function for question 2.

<br/>
<B>1. When measuring height/length of a child who cannot securely stand, place the infant such that his or her feet are flat against the foot board.</B><br/><br/>
<label><INPUT TYPE=radio NAME=question0 VALUE="True"
onClick="setAnswer(0,this.value)">True</label><BR>
<label><INPUT TYPE=radio NAME=question0 VALUE="False"
onClick="setAnswer(0,this.value)">False</label>
<br/>

OK I think I found the problem. one of the brackets was wrong. The alert box is working now. But for some reason question 2 is always wrong. Hm??

Rowsdower!

09-14-2011, 04:26 PM

You had a bunch of "#" characters without escaping them, which caused a javascript error.

Then you had some errors in your handling of the response data. Namely, you can't apply toLowerCase() to an array which was causing it to fail. So a solution there was to apply toString() first and then to run the toLowerCase() after that.

Then you still had some errors in your logic that were going to prevent successful processing so I did a minor overhaul to your page:

You are awesome. Thank you. I hope you don;t mind me asking one more question. What if answers in question 2 were allowed to be in any order? Like: hips,body,knees or knees,hips,body and so on.
In my quiz some answers for the different fill in the blank questions will have to be in order and some not (like for example question 2 does not). Any suggestion?
I REALLY appreciate you helping me on this. You are great!!!

lm111

09-15-2011, 02:07 PM

Could someone please help me with my last question????? I would appreciate it. Thank you.....