Or you can use $('#elem').is(':checked')

2008/1/11, James Dempster <[EMAIL PROTECTED]>:
>
>
> $().ready(function() {
>         $('#editOptions').click(function() {
>             alert($('input:checkbox[name=listProductID]:checked')); //
> returns only the first value, selected or not
>         });
> });
>
> untested but should work.
>
> Also see,
> http://docs.jquery.com/Selectors/checkbox
> http://docs.jquery.com/Selectors/checked
>
> p.s.
> #listProductID will select a single element which has an ID of
> listProductID as none of your inputs have that ID I don't see how it's
> selecting them. they all have the same name so you would need to use
> the attribute selector see
> http://docs.jquery.com/Selectors/attributeEquals#attributevalue
>
> On Jan 11, 5:44 am, Duncan <[EMAIL PROTECTED]> wrote:
> > All,
> >
> > I am lost right now, still pretty green with jQuery. I have a number of
> > checkboxes on a page
> >
> > <input type="checkbox" name="listProductID" value="2">
> > <input type="checkbox" name="listProductID" value="3">
> > <input type="checkbox" name="listProductID" value="4">
> > <input type="checkbox" name="listProductID" value="5">
> >
> > and a button at the end.
> >
> > <button name="editOptions" id="editOptions">Edit </button>
> >
> > I would like to have the value of alll checked checkboxes put into a
> list
> > for use in a variable.
> >
> > how would I go about this?
> >
> > $().ready(function() {
> >         $('#editOptions').click(function(){
> >             alert($('#listProductID').val());//returns only the first
> value,
> > selected or not
> >         });
> >     });
> >
> > Thanks
> >
> > --
> > Duncan I Loxton
> > [EMAIL PROTECTED]
>



-- 
Yılmaz Uğurlu ~ jabber : [EMAIL PROTECTED]  ~ http://www.2nci.com ~ İzmir

Reply via email to