Coding problem on web page with php, java script, html, and xml

0 views
Skip to first unread message

Dan Healy

unread,
Apr 5, 2013, 2:44:33 PM4/5/13
to Ubuntu Texas Local Community Team, ubuntu-ho...@googlegroups.com
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>&lt;b&gt;<?php echo $question_text;?>&lt;/b&gt;</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:

Inline image 2



Second screen shot:

Inline image 3
Screenshot from 2013-04-05 13:07:21.png
Screenshot from 2013-04-05 13:06:36.png
Reply all
Reply to author
Forward
0 new messages