I have a set of checkboxes in an html form similar to this
<form action = "/submit" method = "POST">
<div class="checkbox checkbox-inline checkbox-danger checkbox-md">
<input type="checkbox" class="styled" id="val1" name="value[]" value="Apple">
<label for="val1"> Apple </label>
</div>
<br>
<div class="checkbox checkbox-inline checkbox-danger checkbox-md">
<input type="checkbox" class="styled" id="val2" name="value[]" value="Banana">
<label for="val2"> Banana </label>
</div>
<br>
<div class="checkbox checkbox-inline checkbox-danger checkbox-md">
<input type="checkbox" class="styled" id="val3" name="value[]" value="Pear">
<label for="val3"> Pear </label>
</div>
<br>
<div class="checkbox checkbox-inline checkbox-danger checkbox-md">
<input type="checkbox" class="styled" id="val4" name="value[]" value="Grinadella">
<label for="val4"> Grinadella </label>
</div>
</form>
The form content is stored in a database. The storage works, however I can only get the value of the first checkbox and store it in the database. What I want to do is that if the user selects the first three checkboxes, I want to store the value Apple, Banana, Pear in the database separated by commas.
How can I do this. I know that in PHP there is a function called implode that does this, but how can I extend the form so that I get all values of checked checkboxes in JS/Node.js
thanks in advance