0
I’m having a hard time getting the value of checkboxes marked through jQuery after a Ubmit. It turns out that the input checkbox fields are generated dynamically by a database query, and I’m not knowing how to take them in a generic way. Example of PHP code:
foreach($items as $i){
echo "<input type='checkbox' id='termo'>".$i['nome']."<br/>";
}
Jquery
$("#buttonSubmit").on('click', function(event){
event.preventDefault();
$('#termo').get(0);
});
How to get checkbox marked from multiple input fields with the same id?
normally javascript takes only one element per id, if you want it to perform an action with multiple inputs it should give the same class not the same id.
– Vinicius De Jesus
Wouldn’t it be easier to get the "name" of the checkbox? Id usually tends to be unique by html element.
– Deividson Oliveira