Radio Button how to set up please help me

Asked

Viewed 66 times

1

I’m doing an app creation project here at college aimed at power generator, for this we are using the Eclipse, in case you would like to know

if(radioButton1.isChecked()){

How do you make it when the person clicks on that button to send a reply? I await reply

1 answer

0

You can create a listener for the radio, but it makes no sense to check if it’s checked, because the radio will always be checked when clicked (unlike checkbox, which can be checked and unrecognised).

The listener would be like this:

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

Where the id of radio you wish 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" />

Browser other questions tagged

You are not signed in. Login or sign up in order to post.