how can i post the value of checked checkbox in php script, using ajax call i.e when the user click on checkbox the value is post to php script.
put on checkbox onclick event:
<input type='ceheckbox' onclick='postwithajax(this)' />
and make a function like:
function postwithajax(e){
//and here send with ajax e.checked
}
use jquery to get values from html
$("#submit").click(function(){
var myarray = [];
$("#div input:checked").each(function() {
myarray.push($(this).val()); //push each val into the array
});
// here post Array with ajax
});
Html
<html>
<head>
</head>
<body>
<div id="div">
<input type="checkbox" value="one_name" checked>
<input type="checkbox" value="one_name1">
<input type="checkbox" value="one_name2">
<input type="button" value="submit" id="submit">
</div>
<textarea id="t"></textarea>
</body>
</html>