How to send CheckBox Values in Groups?

Hi there

this is my jsfiddle

What I want is on click of Submit button all values which are Inside a Div will be sent as form of group or Array to server side script

Is it possible?


To send the values to the server you need to add names to them so that the server knows what to refer to them as.

some code snipshot please


Now you can access it in PHP POST as an array. Put that on all the checkboxes.

depending on the server side language being used the may need to be omitted

1 Like

Actually, from your fiddle, i can see where your THINKING is wrong.

REMEBMBER, you MUST named all your FROM INPUTS, in forever for them to to be submitted. Naming the container, doesn’t really do anything, and is even a deprecated practice in general, tho that has nothing to do with form processing.

What you want to do is pass the each element as an array item. Which is what Ryan was trying to to say by adding name=“language”… so it would look like

<form id="registerCourses">
<div id="checkboxblock">
    <input type="checkbox" value="Java"  name="userCourses[]"/>Java<br>
    <input type="checkbox" value="Android" name="userCourses[]"/>Android<br>
    <input type="checkbox" value="Web Design" name="userCourses[]"/>Web Design<br>
    <input type="checkbox" value="Graphic Design" name="userCourses[]"/>Graphic Design<br>
    <input type="submit"  value="Submit"/>

upon submittal your POST/GET array will contain a sub array ‘userCourse’ containing the names of the selected courses which you can then process as needed

I am using JSP in backend but its not working

More detail Click Here

so get rid of the at the end of the names as that is for PHP only.

Thanks @felgall

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.