Obtenir la valeur du bouton radio JavaScript
document.querySelector('input[name="rate"]:checked').value;
Vast Vole
document.querySelector('input[name="rate"]:checked').value;
//html
<input type="radio" name="someName" value="value1">
<label>value1</label>
<input type="radio" name="someName" value="value2">
<label>value2</label>
//js
const radioButtons = document.querySelectorAll('input[name="someName"]');
var selectedRadioButton;
for (const radioButton of radioButtons) {
if (radioButton.checked) {
selectedRadioButton = radioButton.value;
break;
}
}
//now you have the value selected in selectedRadioButton
document.querySelectorAll('input[name="gender"]:checked').value;
document.querySelector('input[name="kala"]:checked').value;