How to get value of selected radio button?

前端 未结 28 2277
温柔的废话
温柔的废话 2020-11-22 03:51

I want to get the selected value from a group of radio buttons.

Here\'s my HTML:

28条回答
  •  广开言路
    2020-11-22 04:57

    In Javascript we can get the values by using Id's "getElementById()" in the above code you posted has contain name not Id so you to modify like this

    if (document.getElementById('r1').checked) {
      rate_value = document.getElementById('r1').value;
    }
    

    use this rate_value according to your code

提交回复
热议问题