I want to insert multiple checkboxes and input text fields but the issues is if i am filling 3 input fields in sequence and select 2 check boxes 1st and 3rd than below function will add all checkbox vales but i want to skip the 2nd value of check box only because its not selected.
for ex:
<input id="answer" type="text" name="answer[]">
<input id="ifcorrect" type="checkbox" name="ifcorrect[]">
input: A Checkbox: selected
input: B Checkbox: not selected
input: C Checkbox: selected
in db i want to insert as below
A 1
B 0 //0 because its not selected
C 1
i am using Laravel
foreach ($data['answer'] as $key => $value) {
$answer = new Answer();
$answer->answer = $value;
$answer->correct = $data['correct'][$value];
$question->answer()->save($answer);
}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2BqPhLi
via IFTTT
Aucun commentaire:
Enregistrer un commentaire