15th Nov 2017, 5:37 PM
Александр Нестеров
Александр Нестеров - avatar
4 Answers
+ 4
On the button, change it to onclick instead of onchange. Also, look at how I changed your function in order to figure out which radio button is selected. That should do the trick for you. https://code.sololearn.com/WzK6okZ0Ye4X/#html <input type="radio" name="ch" value="1">0-10 <input type="radio" name="ch" value="2">11-20 <input type="radio" name="ch" value="3">21-31 <button onclick="chg();">узнай</button> <script> function chg() { var g = document.querySelector('input[name = "ch"]:checked').value; alert('проездной на ' + g + 'декаду'); } </script>
15th Nov 2017, 5:58 PM
AgentSmith
+ 2
You're welcome.
15th Nov 2017, 7:20 PM
AgentSmith
+ 1
thanks Netkos
15th Nov 2017, 6:37 PM
Александр Нестеров
Александр Нестеров - avatar