Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem with <select> tag in php and ajax
    primarykey
    data
    text
    <p>I have this code (below) that works on FF&amp;Chrome but doesn't work on IE*. I am trying to populate the select tag with email address. Thanks</p> <p>question.php</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; function myFunction(val) { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("POST","qsrcipt.php?q="+val,true); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } } xmlhttp.send(); } &lt;/script&gt; &lt;/head&gt; &lt;body onload="myFunction(document.myForm.mySelect.value)"&gt; &lt;form name="myForm" style="float:left; margin-right: 10px; overflow: hidden;"&gt; &lt;select name="mySelect" onchange="myFunction(this.value)" size="10"&gt; &lt;option value="1" selected="selected"&gt;level 1&lt;/option&gt; &lt;option value="2"&gt;level 2&lt;/option&gt; &lt;option value="3"&gt;level 3&lt;/option&gt; &lt;/select&gt; &lt;/form&gt; &lt;div&gt; &lt;select id="myDiv" size="10"&gt;&lt;/select&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>qsrcipt.php</p> <pre><code> &lt;?php // Fill up array with names $lsts = array("Anna","Brittany","Cinderella","Diana","Eva","Fiona"); //get the q parameter from URL $q=$_GET['q']; if ($q == '1') { foreach($lsts as $lst){ echo "&lt;option id='1'&gt;".$lst."&lt;/option&gt;"; } } else { echo "&lt;option id='1'&gt;this is a test&lt;/option&gt;"; } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload