Note that there are some explanatory texts on larger screens.

plurals
  1. POcheck box using onchange
    primarykey
    data
    text
    <p>I have check boxes that get generated dynamically, when the check box is checked the onchange method works fine and my function is called also when the box is unchecked by user the onchange method calls my intended function the problem is when the box is checked a part of the page becomes active which is good but when the user un-checks the checkbox the that part of the page becomes active again, and the value of the checkbox "checked " stays yes after the first time it was checked. Is there way to detect when the user choose to un-check so the active part of the page becomes inactive. </p> <p>her is my code </p> <pre><code>echo '&lt;table width="85%" border="1" cellpadding="0"; cellspacing="0" align="center"&gt; &lt;tr&gt; &lt;th width="23%" height="44" scope="col" align="left"&gt; '.$query_rows['categoryTopic'].' &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/th&gt; &lt;th width="24%" scope="col"&gt;'.$Count.'&lt;/th&gt; &lt;th width="25%" scope="col"&gt; 0 &lt;/th&gt; &lt;th width="28%" scope="col"&gt; &lt;form name = "choose" method="post" action="activateImages.php"&gt; &lt;input type="checkbox" value= "5" onChange="window.edit()" &lt;/form&gt;&lt;/th&gt; &lt;/tr&gt; &lt;/table&gt;'; } ?&gt; </code></pre> <p>Java code:</p> <pre><code>&lt;script type="text/jscript"&gt; //this funciton will be called when user checks a check box. function edit(){ //get selected category from the form //var formName = 'choose'; //var Category = document[formName]['choose'].value; //check if browser suports ajax var xmlhttp = null; if(typeof XMLHttpRequest != 'udefined'){ xmlhttp = new XMLHttpRequest(); } else if(typeof ActiveXObject != 'undefined'){ xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); } else throw new Error('You browser doesn\'t support ajax'); //open connection with activateImages.php to recieve the active images as an acho xmlhttp.open("GET", "activateImages.php",true); //echeck if ready to recieve xmlhttp.onreadystatechange = function (){ if(xmlhttp.readyState == 4) window.activate(xmlhttp); }; xmlhttp.send(null); } //recieve the active images then insert them in the specified location of the page. function activate(xhr){ if(xhr.status == 200){ document.getElementById('images').innerHTML = xhr.responseText; } else throw new Error('Server has encountered an error\n'+ 'Error code = '+xhr.status); } &lt;/script&gt; </code></pre>
    singulars
    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.
    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