Radio Button how to configure please help me

1

I'm doing an application design project here in college for power generator, so we're using Eclipse , in case you'd like to know

if(radioButton1.isChecked()){

How do you do when the person clicks this button to issue a response? I await your response.

    
asked by anonymous 28.11.2017 / 02:28

1 answer

0

You can create a listener for radio , but it does not make sense to check that it is checked, since radio will always be checked when clicked (as opposed to checkbox , which can be checked and unrecognized) .

The listener would look like this:

var radio = document.querySelector('#radioButton1');
radio.addEventListener('click', function(){
   alert("checado");
});

Where id of radio you want to hear is #radioButton1 .

Example:

var radio = document.querySelector('#radioButton1');

radio.addEventListener('click', function(){
   alert("checado");
});
<input id="radioButton1" name="radio" type="radio" />
<input name="radio" type="radio" />
    
28.11.2017 / 02:50