There is a checkbox value. When change the checkbox value I asked from user "Do you want to SHOW this item on website?" or "Do you want to HIDDEN this item on website?"
It is works fine. But the problem is cancel option. If user tick the check box confirm box will appear that "Do you want to SHOW this item on website?". But even user select cancel it will marked as selected. Even I use document.getElementsByName("product").checked = false; to make untick again, it is not worked.
JS Fiddle : http://ift.tt/2sWKDfi
Note : Please No jQuery Solution. Only pure JavaScript.
HTML
<input type="checkbox" name="product" onchange="change_property_status(this.checked);">Option 1
JavaScript
function change_property_status(status){
if(status){
status = 1;
var con_message = confirm("Do you want to SHOW this item on website?");
if(!con_message){
document.getElementsByName("product").checked = false;
return false;
}
} else {
status = 0;
var con_message = confirm("Do you want to HIDDEN this item on website?");
if(!con_message){
document.getElementsByName("product").checked = true;
return false;
}
}
}
Aucun commentaire:
Enregistrer un commentaire