Сообщение от ermak20
|
Сделал так
|
Вариант без цикла...
<form id="mainForm" name="mainForm" action="#">
<input id=gr1 type="radio" name="met" value="1">G-1
<br>
<input id=gr2 type="radio" name="met" value="2">G-2
<br>
<input id=gr3 type="radio" name="met" value="3">G-3
<br>
<input id=gr4 type="radio" name="met" value="4">G-4
<br>
</form>
<script>
document.getElementById("mainForm").addEventListener("click", function () {
var mtd = document.querySelector('[name="met"]:checked');
if (mtd) {
alert("mtd = " + mtd.value);
var x = +mtd.value + 5;
alert("x = " + x);
};
});
</script>