lulu50
asked on
Checkboxes
Hi,
I need to get the value of these checkboxes in a list.
Thank you
I need to get the value of these checkboxes in a list.
My checkboxes:
<input type="checkbox" class="ChkCatg" name="Chk1" id="Chk1" value="1" />
<input type="checkbox" class="ChkCatg" name="Chk2" id="Chk2" value="2" />
<input type="checkbox" class="ChkCatg" name="Chk3" id="Chk3" value="3" />
<input type="checkbox" class="ChkCatg" name="Chk4" id="Chk4" value="4" />
I need jquery to loop thru my checked checkboxes and have the value as a list.
I just want the checkboxes that are checked.
so the output will look like this:
var Catg = (1,3,4);
function AdHocRpt()
{
//loop thru the checked checkboxes
//get the value as a list
var Catg = (1,3,4);
}
Thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Gary,
I fixed it!!!!
Thank you
I fixed it!!!!
Thank you
var checkboxes = $('input:checkbox.ChkCatg:checked').map(function() {
return this.value;
}).get();
ASKER
Thank you
I was away, you only need the following but what you came up with is good
var checkboxes = $(.ChkCatg:checked').map(function() {
return this.value;
}).get();
ASKER
Thank you for the example:
just one thing, that I need to fix.
Open in new window