The unchecking and checking after submit works if i don't use this line of code to load the data everything works. echo ($extraServices == 'Park') ? "checked='checked'" : (($extraServices == 'Park,Electricity') ?
<input type="checkbox" name="services[]" value="Park" <?php
echo ($extraServices == 'Park') ? "checked='checked'" : (($extraServices == 'Park,Electricity') ? "checked='checked'" : "");
if(isset($_POST['services'])) {
if(in_array("Park", $_POST['services'])) {
echo "checked='checked'";
}
}
?>> Park
So now if use echo "checked='checked'";
and echo ($extraServices == 'Park') ? "checked='checked'" : (($extraServices == 'Park,Electricity') ? "checked='checked'" : "");
together. It doesn't work. So with this code it will load the data from the database on which checkbox was checked. That works. But if i uncheck a checkbox it wont be unchecked after submit. How can i solve this? I thought about a way to detect if i load this page for the first time. But then i bumped into the problem that that was for loading the page the first time EVER.
I wanted to come up with something to detect if the page loads and loads the data. After that it doesn't need to load the data from the database. But i don't know how i could do this.
I dont know what to do now, hope that someone got some idea's?
Thanks for your help.
Aucun commentaire:
Enregistrer un commentaire