Question: Hi i am new to javascript and having some trouble. 

I need my function to take the user input "recserv" and multiply it by the value of the selected radio button, as well as update if the value is changed or the radio button is changed.

Changing the radio buttons seems to work, but I get an error when the "recserv" value is changed.

Thank you for any help! 

```
<script>
function yeartot(service) {
    var recserv = parseFloat(document.getElementById('recserv').value);
    document.getElementById("result").value = service*recserv;
}
</script>
<body>

<p>Select the frequency</p>
  <input onclick="yeartot(this.value)" type="radio" name="service" value="11">Monthly<br>
  <input onclick="yeartot(this.value)" type="radio" name="service" value="6" checked> Bi-Monthly<br><br>

 Recurring Service Amount <input onchange="yeartot()" id="recserv" value=0><br/><br/>

  Total for year <input type="text" id="result">

```

Answer: 
simply this...

```js
document.getElementById('my-form').addEventListener('input', function () {
  this.result.textContent = parseFloat(this.recserv.value) * parseInt(this.service.value)
})
```

```html
<form id="my-form" onsubmit="return false">
  <p>Select the frequency</p>
  <input type="radio" name="service" value="11">Monthly
  <br>
  <input type="radio" name="service" value="6" checked> Bi-Monthly
  <br><br>

  Recurring Service Amount <input name="recserv" value="0">
  <br /><br />

  Total for year <output name="result"></output>

</form>
```

-- adding a form makes things easier if each entry (or output) has a name.  

-- using a form element, you do not need to use any ID, and you do not need to see which radio button is checked, you directly take the selected value  

-- and do not use a change event but use input event
> 
> Change your script into this
> 
> 
> 

```
<script>
      const input = document.getElementById("recserv");
      const result = document.getElementById("result");
      function yeartot(service) {
        const checkedService = document.querySelector(":checked");
        var recserv = Number(document.getElementById("recserv").value);
        document.getElementById("result").value =
          Number(checkedService.value) * Number(input.value);
      }
    </script>

```