Alert when form radio selected

Hello.

This does not work.

What is wrong?


Thanks!

<form>
<input type="radio" name="r" value="1" onselect="alert('1');">
<input type="radio" name="r" value="2" onselect="alert('2');">
<input type="radio" name="r" value="3" onselect="alert('3');">
<input type="radio" name="r" value="4" onselect="alert('4');">
</form>
LVL 16
hankknightAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
pradeepsudharsanConnect With a Mentor Commented:
use onclick and onkeypress
            <input type="radio" name="r" value="1" onclick="alert('1');" onkeypress= "Form1.r.checked=true;alert('1');">
0
 
0h4crying0utloudCommented:




I think you mean "onclick"
0
 
hankknightAuthor Commented:
Hello.

One problem with onclick is that it does not work if the user uses their keybord (tab and arrow keys) to select an item.
0
 
thirdCommented:
onclick should work. tab sets the focus and space bar or arrow keys selects it.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.