I tried to make value with checkbox, if checked the value is active but if uncheck the value its disabled..
this code its work for the text, text its change when i clicked check or uncheck, but value to post to database is null
HTML
<input type="checkbox" name="cat_status" class="inline checkbox" id="checkbox" checked value="active" onclick="cat_check()"> < label id="text" style="display:Active">Active</label>
JS
function cat_check() {
var checkBox = document.getElementById('checkbox');
var text = document.getElementById('text');
if (checkBox.checked == false){
text.style.display = "inline";
document.getElementById('checkbox').value = "active";
} else {
text.style.display = "none";
document.getElementById('checkbox').value = "disable";
}
}
i expect the value post to database is disabled when the checkbox in uncheck
Aucun commentaire:
Enregistrer un commentaire