+ 1

Radiobuttons not working

I'm trying to display a message when a particular radiobutton is selected. Code below: https://code.sololearn.com/WveVisYko7PD It ain't working.Please check.

13th Feb 2020, 3:55 PM
Tanmoy
3 Answers
+ 2
You are now checking only at beginning. You should use onchange event listener instead. https://code.sololearn.com/W01ZUJa8VQA5/?ref=app Or a easier way, add your function as click callback to a button. https://code.sololearn.com/WU0cgiMBknhI/?ref=app
13th Feb 2020, 3:57 PM
Gordon
Gordon - avatar
+ 1
I have chosen the easy way with onclick attribute and onchange attribute in HTML tags. A better way is to use addEventListener so that we can add more event listeners and also remove unnecessary event listeners later. That will be after your DOM lessons.
13th Feb 2020, 4:11 PM
Gordon
Gordon - avatar
0
Thank you Sir (Gordon) for your quick reply. That was so simple.
13th Feb 2020, 4:03 PM
Tanmoy