fetch the values of selected checkbox array using JQuery

fetch the values of selected checkbox array using JQuery

Postby tomrff » Thu Apr 28, 2011 1:42 pm

suppose that below is checkbox array
<input type=”checkbox” value=”1″ name=”Items[]“ id=”Items1″ />
<input type=”checkbox” value=”2″ name=”Items[]“ id=”Items2″ />
<input type=”checkbox” value=”3″ name=”Items[]“ id=”Items3″ />
<input type=”checkbox” value=”1″ name=”Items[]“ id=”Items4″ />

and we want the get the value of selected checkbox using jquery.

then simple use below code.
var selItems = new Array();
$(input[@name='Items[]‘]:checked”).each(function() {selItems .push($(this).val());});

Here selItems will take all selected value of checkbox
tomrff
 
Posts: 33
Joined: Sat Jan 08, 2011 10:12 pm

Return to JQuery

Who is online

Users browsing this forum: No registered users and 1 guest

cron