The documentation suggests that checkboxes should work as well as select
boxes, so this may be a bug:
http://docs.jquery.com/Attributes/val

- Richard

On Mon, Oct 5, 2009 at 4:51 AM, Justinas Urbanavicius
<[email protected]>wrote:

> thanks. although it's weird that .val() || [] works when fetching multiple
> values of multiple select box.
>
>
> On Mon, Oct 5, 2009 at 11:28 AM, James Padolsey <
> [email protected]> wrote:
>
>>
>> This is just the way jQuery works. All getters only return the first
>> result.
>>
>> To avoid this you could use jQuery.map:
>>
>> var values = jQuery.map( $('input.file_attachment'), function(input){
>>    return $(input).val();
>> });
>>
>> If you think you'll want this functionality more than once then I'd
>> suggest making a slight modification, allowing you to retrieve results
>> as an array by passing true (as the first argument) to any getter,
>> e.g.
>>
>> $('a').attr('href'); // get's first HREF only
>> $('a').attr(true, 'href'); // get's ALL HREFs
>>
>> To make this work you'll need to use this code:
>> http://gist.github.com/201983
>>
>> Hope that helps...
>>
>> On Oct 4, 10:18 pm, Gamesh <[email protected]> wrote:
>> > Hi,
>> >
>> > i can't figure out why gettting multiple values doesn't work
>> >
>> > i have to checkbox'es:
>> >
>> > <label style="font-size: 12px; display: block;">
>> > <input class="file_attachment" type="checkbox" checked="checked"
>> > value="6" name="file[]"/>
>> > ninja-assassin-337x500.jpg 49.82 K
>> > </label>
>> >
>> > <label style="font-size: 12px; display: block;">
>> > <input class="file_attachment" type="checkbox" checked="checked"
>> > value="5" name="file[]"/>
>> > 9 final movie poster Shane Acker.jpg 391.06 K
>> > </label>
>> >
>> > when selecting $('input.file_attachment') return two objects which is
>> > good.
>> > but when i try to extract the values like in documentatioin
>> >
>> > $('input.file_attachment').val() || []
>> >
>> > it return only the first value 6, instead of array of values [6, 5].
>> > why is that?
>>
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" 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/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to