On 12/14/06, Jorge Godoy <[EMAIL PROTECTED]> wrote:
> "Arnar Birgisson" <[EMAIL PROTECTED]> writes:
>
> > On 12/13/06, Arnar Birgisson <[EMAIL PROTECTED]> wrote:
> >> var selectedvalue = filter(
> >> itemgetter('checked'),
> >> $$('#radios input[name=test])
> >> )[0].value;
> >>
> >> You end up with "undefined" if no radio is checked.
> >
> > Sorry, that is not correct. filter(...)[0] is undefined if no radio is
> > checked, but adding ".value" of course causes an "object has no
> > property 'value'" error.
>
> Is the recommended approach to check if the object is defined before accessing
> its ".value"?
To avoid getting an error, yes.
var radiobutton = filter(
itemgetter('checked'),
$$('#radios input[name=test])
)[0];
var selectedvalue = (radiobutton != undefined) ? radiobutton .value : null;
Arnar
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---