samedi 20 octobre 2018

get chechbox selected value

I have multiple checkboxes that get generated by a php code and the HTML looks like this:

<input name="checkbox" id="checkbox" value="firstBox" type="checkbox">
<input name="checkbox" id="checkbox" value="secondBox" type="checkbox">

However when I try to get the selected value by the user using below script

document.getElementById('checkbox').value

I always get 'firstBox' even when the secondBox is selected. Please help me solving this




Aucun commentaire:

Enregistrer un commentaire