Note that there are some explanatory texts on larger screens.

plurals
  1. POReturn Multiple checkbox in AJAX response
    primarykey
    data
    text
    <p>I have 2 php pages, the Page1 contain (html + javascript + php code), the page2 contain php code only.</p> <p>so, Inside page1, ther's a dropdown contain many values, if i choose one of them, the AJAX code get value to page2.php like this: </p> <p>If i replace the checkbox input with a Drop down, the script work perfectly, but in this case, it don't work.</p> <p>The aim is to display the results of page2 as a checkbox's on page1. Any idea?</p> <p>Page1.php:</p> <p>HTML CODE:</p> <pre><code> &lt;select onChange="getdids(this.value)" id="groupSelect" name="groupSelect" &gt; &lt;option value="0"&gt;xxx&lt;/option&gt; &lt;option value="1"&gt;yyy&lt;/option&gt; &lt;option value="2"&gt;zzz&lt;/option&gt; &lt;option value="3"&gt;vvv&lt;/option&gt; &lt;/select&gt; &lt;input type="checkbox" id="alldids" name="alldids" value="0"&gt;did&lt;br&gt; </code></pre> <p>AJAX CODE:</p> <pre><code> &lt;script&gt; function getdids(str) { if (str=="") { document.getElementById("alldids").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) { document.getElementById("alldids").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","page1.php?groupName="+str,true); xmlhttp.send(); } &lt;/script&gt; </code></pre> <p>Page2.php:</p> <p>PHP CODE:</p> <pre><code> &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Get dids&lt;/title&gt; &lt;/head&gt; &lt;?php require_once('../functions.php'); include('../variables.php'); $didGrpName=$_GET['groupName']; $didGrpId=GroupId($table_groups,$didGrpName); $x=array(); $x=showDidOfGroup($didGrpId); $i=1; while($i &lt;= $x[$i]){ ?&gt; &lt;input type="checkbox" value="&lt;?php echo $x[$i]; ?&gt;"&gt;&lt;?php echo $x[$i]; ?&gt;&lt;br&gt; &lt;?php $i++; } ?&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&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