Jump to content

Events And Radios


shadowayex

Recommended Posts

I'm having a little problem. I'm using JavaScript validation on a form and I'm trying to make it slightly automated. Here's what's happening:Let's say you have two radios, and the first one was selected, something like this:

<input type="radio" name="radios1" checked="checked" value="1" /> Option 1<input type="radio" name="radios1" value="2" /> Option 2

Let's say you added a JavaScript event, whether it be onfocus, onblur, onclick, onmousedown, onmouseup, etc. (all the ones I tried followed the behavior that I'm about to explain), you've added one to launch a function to detect which one is checked.My problem is that if the first one is checked, and you check the second one, it still detects the first one is checked. But if you went back to the first one, the second one is detected. It seems teh events are launched before the check effect is activated.Is there any way to reverse this?

Link to comment
Share on other sites

It seems teh events are launched before the check effect is activated.
Correct, because it gives you an opportunity to return false and cancel the event. Pass the radio button to the function so that you can use that to tell which was clicked. e.g.:onclick="func(this);"
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...