Hello Everyone,
I posted this question earlier under creating Multiple choice quiz. Is
it possible to ignore something using javascript. What I am trying to
do is creating a multiple answer quiz. I have five choices out of
which user are supposed to choose 3 best choices. The user should get
feedback on the choices they make. I have been able to provide the
feedback for all the choices but my problem is I am also getting the
feedback on the unchecked answers. Is there any way to tell javascript
not to check unchecked answers.
I have used the following code to accomplish this:
function check(f,key){
var newhtml="";
key=key.replace (/^.*0/,"").substr(0,5 );
for(var i=0;i<key.lengt h;i++) {
if ((key.charAt(i) <"5")==f.elemen ts[i].checked)
{
newhtml+= question.a[i] + "<br>Right.<br> ";
}
else if ((key.charAt(i) >"5")==f.elemen ts[i].checked)
{
newhtml+= question.a[i] + " <br>Wrong.<br>" ;
} else {return};
}
document.getEle mentById("table t").innerHTM L= newhtml;
Could anyone help me with what's wrong with this code. Any help would
be appreciated.
Thanks
I posted this question earlier under creating Multiple choice quiz. Is
it possible to ignore something using javascript. What I am trying to
do is creating a multiple answer quiz. I have five choices out of
which user are supposed to choose 3 best choices. The user should get
feedback on the choices they make. I have been able to provide the
feedback for all the choices but my problem is I am also getting the
feedback on the unchecked answers. Is there any way to tell javascript
not to check unchecked answers.
I have used the following code to accomplish this:
function check(f,key){
var newhtml="";
key=key.replace (/^.*0/,"").substr(0,5 );
for(var i=0;i<key.lengt h;i++) {
if ((key.charAt(i) <"5")==f.elemen ts[i].checked)
{
newhtml+= question.a[i] + "<br>Right.<br> ";
}
else if ((key.charAt(i) >"5")==f.elemen ts[i].checked)
{
newhtml+= question.a[i] + " <br>Wrong.<br>" ;
} else {return};
}
document.getEle mentById("table t").innerHTM L= newhtml;
Could anyone help me with what's wrong with this code. Any help would
be appreciated.
Thanks
Comment