1
I have a group of checkboxes that are generated from the BD, therefore their id will be different. In my case 3 checkboxes are generated:
HTML:
<input type="checkbox" id="[email protected]()" name="teste" class="checkbox style-0">
<span>@tpEnt.getDescricao()</span>
Javascript
myJSRoutes.controllers.---Controller.addExemplo().ajax({
data : {
teste: $("input[name=teste] :checked").val()
}
});
Controller (Java)
System.out.println("Teste: " + form.data().get("teste"));
output: 'ON' (when one of the 3 checkboxes is selected). I would like to know how to side the controller
I can get the id of the checkbox
selected and not knowing if one of the three is selected.
Edited:
If instead of:
teste: $("input[name=teste] :checked").val()
Put:
teste: $("input[name=teste]").attr('id')
always returns Check1.
Put:
teste: $("input[name=teste] :checked").attr('id')
returns null
All your checkboxes always have the same value as the "name attribute"?
– WoF_Angel
The user can select none, one and/or more of a checkbox?
– WoF_Angel