I have some javascript that checks whether or not an answer is correct. It was working fine when the question was asked with text but now that I'm asking the question with audio, the javascript no longer works. (I think it is considering the embed tag as an element in my form and I think that's causing the problem.) I think adding and specifying to only look at a div tag within the form would solve the problem but I'm not sure. Can someone check this out and see if you have a solution?
//this checks whether the answer is correct (worked fine when question was typed in text but no longer works when the question is asked with audio).
[HTML]var score = 0;
var answer = new Array("pass","b rag","drag","be gan","else","he ld","felt","kep t","smell");
function check(){
for(i=0;i<answe r.length;i++){
//answer.lenght is the lenght of the answer array
if(document.myf orm.inputs[i].value.toLowerC ase()==answer[i]){
score++;
var p=i+1;
var str="showpictur e"+p;
var str2="showwrong "+p;
var score2=score/9*100
var percentage=scor e2.toFixed(0) + '%';
document.getEle mentById(str).s tyle.visibility ="visible";
document.getEle mentById(str2). style.visibilit y="hidden";
document.myform .score.value=sc ore;
document.myform .percentage.val ue=percentage;
document.myform .time.value=get LessonTime();
document.myform .time.value=get LessonTime();
}
else
{
if(document.myf orm.elements[i].value!=""){
document.myform .elements[i].value="Try Again";
var p=i+1;
var str="showpictur e"+p;
var str2="showwrong "+p;
document.getEle mentById(str).s tyle.visibility ="hidden";
document.getEle mentById(str2). style.visibilit y="visible";
}}}
score = 0;
}
//heres the beginning of the form (I think the embed tag is causing the problem)
<form name="myform" method="post" action="<cfoutp ut>#CurrentPage #?#CGI.QUERY_ST RING#</cfoutput>" onSubmit="retur n validateForm(th is)"">
<p> </p>
<p align="right" class="smalltex t">Activity # 2019 </p>
<table border="1" align="center" cellpadding="5" cellspacing="1" bordercolor="#D 5CCBB" bgcolor="#00000 0">
<tr>
<td width="200" bgcolor="#00FF0 0" class="bigtext" ><div align="center"> Problem</div></td>
<td width="100" bgcolor="#00FF0 0" class="bigtext" ><div align="center"> Answer</div></td>
<td width="100" bgcolor="#00FF0 0" class="bigtext" ><div align="center"> Feedback</div></td>
</tr>
<tr>
<td bordercolor="#D 5CCBB" bgcolor="#FFFF0 0" class="bigbluet ext"><p><span class="previewD iv" style="WIDTH: 240px; HEIGHT: 27px">
<embed name="" src="../media/spellingwords/1.mp3" width="240" height="27" type="audio/x-wav" alt="Click play button to hear word." autoplay="false " controller="tru e" loop="false" /> </embed>
</span></p> </td>
<td bordercolor="#D 5CCBB" bgcolor="#FFFF0 0"><label><d iv>
<input type="text" name="1" size="8" onBlur="check() " />
</label></td>
<td bgcolor="#FF000 0">
<img src="../images/generalimages/star.gif" alt="Correct" width="48" height="44" id="showpicture 1" style="visibili ty:hidden;" /><img src="../images/generalimages/blackx.gif" alt="Wrong" width="48" height="44" id="showwrong1 " style="visibili ty:hidden;" /></td>[/HTML]
//this checks whether the answer is correct (worked fine when question was typed in text but no longer works when the question is asked with audio).
[HTML]var score = 0;
var answer = new Array("pass","b rag","drag","be gan","else","he ld","felt","kep t","smell");
function check(){
for(i=0;i<answe r.length;i++){
//answer.lenght is the lenght of the answer array
if(document.myf orm.inputs[i].value.toLowerC ase()==answer[i]){
score++;
var p=i+1;
var str="showpictur e"+p;
var str2="showwrong "+p;
var score2=score/9*100
var percentage=scor e2.toFixed(0) + '%';
document.getEle mentById(str).s tyle.visibility ="visible";
document.getEle mentById(str2). style.visibilit y="hidden";
document.myform .score.value=sc ore;
document.myform .percentage.val ue=percentage;
document.myform .time.value=get LessonTime();
document.myform .time.value=get LessonTime();
}
else
{
if(document.myf orm.elements[i].value!=""){
document.myform .elements[i].value="Try Again";
var p=i+1;
var str="showpictur e"+p;
var str2="showwrong "+p;
document.getEle mentById(str).s tyle.visibility ="hidden";
document.getEle mentById(str2). style.visibilit y="visible";
}}}
score = 0;
}
//heres the beginning of the form (I think the embed tag is causing the problem)
<form name="myform" method="post" action="<cfoutp ut>#CurrentPage #?#CGI.QUERY_ST RING#</cfoutput>" onSubmit="retur n validateForm(th is)"">
<p> </p>
<p align="right" class="smalltex t">Activity # 2019 </p>
<table border="1" align="center" cellpadding="5" cellspacing="1" bordercolor="#D 5CCBB" bgcolor="#00000 0">
<tr>
<td width="200" bgcolor="#00FF0 0" class="bigtext" ><div align="center"> Problem</div></td>
<td width="100" bgcolor="#00FF0 0" class="bigtext" ><div align="center"> Answer</div></td>
<td width="100" bgcolor="#00FF0 0" class="bigtext" ><div align="center"> Feedback</div></td>
</tr>
<tr>
<td bordercolor="#D 5CCBB" bgcolor="#FFFF0 0" class="bigbluet ext"><p><span class="previewD iv" style="WIDTH: 240px; HEIGHT: 27px">
<embed name="" src="../media/spellingwords/1.mp3" width="240" height="27" type="audio/x-wav" alt="Click play button to hear word." autoplay="false " controller="tru e" loop="false" /> </embed>
</span></p> </td>
<td bordercolor="#D 5CCBB" bgcolor="#FFFF0 0"><label><d iv>
<input type="text" name="1" size="8" onBlur="check() " />
</label></td>
<td bgcolor="#FF000 0">
<img src="../images/generalimages/star.gif" alt="Correct" width="48" height="44" id="showpicture 1" style="visibili ty:hidden;" /><img src="../images/generalimages/blackx.gif" alt="Wrong" width="48" height="44" id="showwrong1 " style="visibili ty:hidden;" /></td>[/HTML]
Comment