hello I have problem in reading and sending checkbox value I tried using ajax but it didn't work what the wrong with my ajax????!!! " what I really need is to retrieve the value " . $row['ID'] . " and write statement to insert value to the db in case it was checked ?!"
function defaultt(id) {
$.ajax({
type : "POST",
data : "id=" + id,
url : "defaultt.php",
success : function(msg) {
$('#' + id).fadeOut(300);
}
});
code:
<td><form><input type="checkbox" name="state" id="state"class="check" checked onClick='javascript:defaultt(" . $row['ID'] . ");' >
retrieve code in other page.php:
<?php $id1 = intval($_POST['id']);
if (isset($id1)) {} ?>
I also used this code but didn't work :(
<?php if ($_POST['state']){?>
<script type=text/javascript>
function validate(){
if(state.checked == 1){
alert("checked") ;}else{
alert("You didn't check it! Let me check it for you.")
}
}
</script>
<?php}?>
"id="not state$_POST['state']checkedstate of the checkbox. Note also that you don't need thejavascript:label in an inline event attribute.