lundi 22 juin 2015

Update the value of checkbox

I'm having problem when updating the value of checkbox. Below show the checkbox that I would like to update.

The value of checked box;

Annual Leave and Marriage Leave = 1

while the unchecked box;

Maternity Leave and Sick Leave = 0

enter image description here

My code :

if(isset($_POST['update']))
{
   $leave_al = !empty($_POST['leave_al']) ? 1 : 0;
   $leave_matl = !empty($_POST['leave_matl']) ? 1 : 0;
   echo $leave_al;
   echo $leave_matl;
}

This is the example code for annual leave and marriage leave to show you the example.The annual leave from the value = 1 when uncheck will turn to the value = 0. However, for maternity leave from the value = 0, when check the value will still remain as 0. What should I change to my code because I have tried adjusting the code and it is still not working. Thanks!




Aucun commentaire:

Enregistrer un commentaire