shadowayex Posted October 9, 2009 Share Posted October 9, 2009 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 More sharing options...
justsomeguy Posted October 9, 2009 Share Posted October 9, 2009 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 More sharing options...
shadowayex Posted October 9, 2009 Author Share Posted October 9, 2009 Oh, makes sense now .That'll do it. Thanks. Link to comment Share on other sites More sharing options...
jeffman Posted October 9, 2009 Share Posted October 9, 2009 "func(this);". . . && horse.rodeInOn. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.