I made a code that creates a list of multiple-checkbox from query, this code allows me to select group of choices either from the parent choice or individually everything is fine with me till the moment of echo the selected check-boxes in the input textbox, i don't know how to do that!
I'd like to get only the selected check-boxes of the children choices into the input text box like this name1, name2, ...etc
<input type="text" class="form-control" name="checkbox" value=""/>
<?php
$query=mysqli_query($db,"SELECT * FROM tblmainjobs");
while ($row = mysqli_fetch_assoc($query)):
?>
<section>
<h3>
<label><input type="checkbox" /> <?php echo $row["mainjob"]; ?></label>
</h3>
<?php
$query2=mysqli_query($db,"SELECT userjob FROM users WHERE usertype = 'user' AND '".$row["mainjob"]."' = users.mainjob GROUP BY users.userjob, users.usertype");
while ($row2 = mysqli_fetch_assoc($query2)):
?>
<div class="children">
<label><input type="checkbox" name="checkbox"/> <?php echo $row2["userjob"]; ?></label>
<?php
endwhile;
?>
</section>
<?php endwhile; ?>
<script type="text/javascript">
$("h3 input:checkbox").cbFamily(function (){
return $(this).parents("h3").next().find("input:checkbox");
});
</script>
</section>
my list of multiple checkbox is