I believe the problem is in the following java script code segment. A diagnostic php command is highlighted in red. The correct execution of the code is shown in the first screen shot. The incorrect execution of the code is shown in the second screen shot. Some questions are presented correctly and some are not as shown in these two screen shots. I have been unable to figure out what the difference is. This sample was created using Ubuntu 12.04 and Firefox. I get the same results with Chrome on Ubuntu and with IE on MS Windows Vista.
I would appreciate any ideas what might be wrong or where I might look next.
Thanks, Dan H
Code segment:
<div id=main>
<div style="width: 80%">
<?php
if ($question_head != "") echo $question_head."<br />";
echo $question_text."<br />";
?>
<div type="hidden">
<span id="question"></span>
</div>
<script>
txt="<note>";
txt=txt+"<body><b><?php echo $question_text;?></b></body>";
txt=txt+"</note>";
// alert(txt);
if (window.DOMParser)
{
parser=new DOMParser();
xmlDoc=parser.parseFromString(txt,"text/xml");
}
else // Internet Explorer
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.loadXML(txt);
}
document.getElementById("question").innerHTML=xmlDoc.getElementsByTagName("body")[0].childNodes[0].nodeValue;
First screen shot: