how to i get all checkbox values including non checked check-boxes in grails?

230 views Asked by At

How do i get all Non Selected and Selected checkbox values in controller?

Gsp Code :

<g:each in="${userlist}" status="i" var="userInstance">
<g:checkBox name="userInstanceList" value="${userInstance?.id}"/>

</g:each>
1

There are 1 answers

0
Joshua Moore On

By default browsers do not submit values for checkboxes that are not checked. You have two options.

  1. Obtain a list of the set of data in the controller which makes up the entire set and remove the values which are checked, leaving you with the "unchecked" values.

  2. Use Javascript or JQuery to iterate through the checkboxes, collecting the values of the unchecked checkboxes and setting a hidden field to that value. (e.g. 1,4,7).