[Javascript] Dollar function for name=
Terry Riegel
riegel at clearimageonline.com
Mon Jun 7 19:38:59 CDT 2010
On Jun 7, 2010, at 8:23 PM, Philip Thompson <philthathril at gmail.com>
wrote:
> On Jun 7, 2010, at 12:32 AM, Paul Novitski wrote:
>
>> At 6/6/2010 09:46 PM, Philip Thompson wrote:
>>> $$('input[name=pizza]').some(function (el) {
>>> if (el.get('value') == 'sausage') {
>>> el.set('checked', true);
>>> return true;
>>> }
>>> return false;
>>> });
>>
>>
>> Since a radio button group can have only one option checked, we'd
>> want to clear the 'checked' attribute for every non-sausage field:
>>
>> if (el.get('value') == 'sausage')
>> {
>> el.set('checked', true);
>> return true;
>> }
>> else
>> {
>> el.set('checked', false);
>> return false;
>> }
>>
>> or, more concisely although perhaps not as readably:
>>
>> var bState = (el.get('value') == 'sausage');
>> el.set('checked', bState);
>> return bState;
>>
>> Regards,
>>
>> Paul
>
> There shouldn't be a need to uncheck the other (potentially-)
> selected radio buttons. Selecting one will, by default, unselect the
> others with the same name just as if you had clicked on one.
>
> ~Philip
Unless your a belt and suspenders type of person.
More information about the Javascript
mailing list