[thelist] JavaScript: detecting and undoing radio button chan ge

Tom Dell'Aringa pixelmech at yahoo.com
Wed Apr 2 20:21:55 CST 2003

--- Carl J Meyer <cjmeyer at npcc.net> wrote:
> On Wed, 2003-04-02 at 17:01, Joel Canfield wrote:
> > How? Once another is checked, the original obviously isn't.
> > without resorting to 'onblur' how would you do this? Or, is there
> a way to use 'onblur' without driving oneself crazy?

Remember the power of arrays in JS. A radio group has a NAME, and
that group has an array of elements sharing that name.



would give you the first one..etc. So if you want to check (or
recheck) one - say the second one of the group you could do:

document.forms['myForm'].elements['radiogroup'][1].checked = true

You would just put a line like that in your code block where the user
decided he didn't want to check after all, just use the right array
number of the default radio button (which I suppose might be 0 - the
first one.)



var me = tom.pixelmech.webDeveloper();

[Making A Commercial Case for Adopting Web Standards]

"That's not art, that's just annoying." -- Squidward

Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more

More information about the thelist mailing list