I have a problem I created a function to take the value of the input: check and to take its value to return this result to write in the h3
html
<input type="radio" name="check" value="2" /> Option 1
<input type="radio" name="check" value="1" /> Option 2`
<h3 id="r" onchange="test1()"></h3>
function test1 (){
var select= document.querySelector('input[name="check"]:checked').value;
return select
}
var selectbox = test1()
document.getElementById('r').innerHTML = selectbox
`? That doesn’t seem to make any sense. Inline event handlers like `onchange` are [bad practice](/q/11737873/4642212). They’re an [obsolete, cumbersome, and unintuitive](/a/43459991/4642212) way to listen for events. Always [use `addEventListener`](//developer.mozilla.org/en/docs/Learn/JavaScript/Building_blocks/Events#inline_event_handlers_%E2%80%94_dont_use_these) instead. Also, `test1` doesn’t actually _do_ anything except return a value. `test1();` will just discard that value.
– Sebastian Simon Nov 28 '22 at 20:34` element doesn't fire a `change` event. So what's the actual event you want to respond to? A `change` event on the `` elements? Something else?
– David Nov 28 '22 at 20:39