0

I am populating combobox on checkbox checked or not click event.
Here is code. I am not solving the bug, JS runs on chrome but not in both IE and Firefox.

checkbox

<input type="checkbox" onclick="selectinactivebatch(this.value);" id="inactive_batch" name="inactive_batch" <?php if(isset($_POST)) echo "checked";?>>

AJAX Code

function selectinactivebatch(checkboxvalue)
{


var check;
if(checkboxvalue=='on')
check=1;
else
check=0;
alert(check); // Always showing value 1
xmlhttpbatch=GetXmlHttpObjectbatch(this.value);
if (xmlhttpbatch==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="selectBatch.php";
url=url+"?action=inactive_batch_collection";
url=url+"&val="+check;
xmlhttpbatch.onreadystatechange=stateChangedbatch;
xmlhttpbatch.open("GET",url,true);
xmlhttpbatch.send(null);
}


function GetXmlHttpObjectbatch()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}


function stateChangedbatch()
{
if (xmlhttpbatch.readyState==4)
{
document.getElementById("txtBatch").innerHTML=xmlhttpbatch.responseText;
}
}

Edited by pyTony: fixed formatting

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by twiss
0

<input type="checkbox" onclick="selectinactivebatch(this.value);" id="inactive_batch" name="inactive_batch" <?php if(isset($_POST)) echo "checked";?>>

Where is the value of that checkbox ? You must have already put that checkbox value. Like:

<input type="checkbox" onclick="selectinactivebatch(this.value);" id="inactive_batch" name="inactive_batch" value="<?php echo $value; ?>" <?php if(isset($_POST['inactive_batch'])) echo "checked";?>>

Hope this help.

1

Yes, probably you mean this.checked? If you change that and what I said before, it should work (as long as you mean checked, not value).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.