+ 3
why function is don't working
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>
+ 2
You're welcome.
+ 1
thanks Netkos