[jQuery] Re: get value of checked checkboxes into a list

2008-03-07 Thread Rafael Soares


I'm trying exactly the same.
$(input:checkbox:checked); returns a set of jQuery elements
$(input:checkbox:checked).val(); returns the value of the first element in
the set.

I really wanted to get an array with all the values, or even a string,
without the need to iterate over each of the elements.

Thanks


jeangougou wrote:
 
 
 Updating jQuery to 1.2 gives you all the values, as you can see here:
 http://docs.jquery.com/Attributes/val
 else you can use a plugin
 http://www.malsup.com/jquery/form/#fields
 
 pay attention for the result, it might be an array. i haven't checked
 that yet.
 Good luck
 
 Duncan ha scritto:
 
 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=editOptionsEdit /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]
 
 

-- 
View this message in context: 
http://www.nabble.com/get-value-of-checked-checkboxes-into-a-list-tp14750244s27240p15906685.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.



[jQuery] Re: get value of checked checkboxes into a list

2008-03-07 Thread tlphipps

Gonna have to iterate.
jquery selector gives you a jquery object.
$(input:checkbox:checked).each() is your friend.

On Mar 7, 3:27 pm, Rafael Soares [EMAIL PROTECTED] wrote:
 I'm trying exactly the same.
 $(input:checkbox:checked); returns a set of jQuery elements
 $(input:checkbox:checked).val(); returns the value of the first element in
 the set.

 I really wanted to get an array with all the values, or even a string,
 without the need to iterate over each of the elements.

 Thanks



 jeangougou wrote:

  Updating jQuery to 1.2 gives you all the values, as you can see here:
 http://docs.jquery.com/Attributes/val
  else you can use a plugin
 http://www.malsup.com/jquery/form/#fields

  pay attention for the result, it might be an array. i haven't checked
  that yet.
  Good luck

  Duncan ha scritto:

  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=editOptionsEdit /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]

 --
 View this message in 
 context:http://www.nabble.com/get-value-of-checked-checkboxes-into-a-list-tp1...
 Sent from the jQuery General Discussion mailing list archive at Nabble.com.


[jQuery] Re: get value of checked checkboxes into a list

2008-03-07 Thread Mike Alsup

  I'm trying exactly the same.
  $(input:checkbox:checked); returns a set of jQuery elements
  $(input:checkbox:checked).val(); returns the value of the first element in
  the set.

  I really wanted to get an array with all the values, or even a string,
  without the need to iterate over each of the elements.


var valArray = $('input:checkbox').serializeArray();

'tis beautiful!


[jQuery] Re: get value of checked checkboxes into a list

2008-03-07 Thread Dan G. Switzer, II

Rafael,

I'm trying exactly the same.
$(input:checkbox:checked); returns a set of jQuery elements
$(input:checkbox:checked).val(); returns the value of the first element
in
the set.

I really wanted to get an array with all the values, or even a string,
without the need to iterate over each of the elements.

My Field Plug-in has a method called fieldArray() which will do exactly what
you're looking to do:

http://jquery.com/plugins/project/field

-Dan



[jQuery] Re: get value of checked checkboxes into a list

2008-01-18 Thread jeangougou

Updating jQuery to 1.2 gives you all the values, as you can see here:
http://docs.jquery.com/Attributes/val
else you can use a plugin
http://www.malsup.com/jquery/form/#fields

pay attention for the result, it might be an array. i haven't checked
that yet.
Good luck

Duncan ha scritto:

 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=editOptionsEdit /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]


[jQuery] Re: get value of checked checkboxes into a list

2008-01-11 Thread James Dempster

$().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=editOptionsEdit /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]