I have a group of checkboxes that are generated from the DB, consequently 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 on the controller
side I can get the id of the checkbox
selected and not know if one of the three is selected.
Edited:
If instead of:
teste: $("input[name=teste] :checked").val()
If you put:
teste: $("input[name=teste]").attr('id')
always returns Check1.
If you put:
teste: $("input[name=teste] :checked").attr('id')
returns null