fetch the values of selected checkbox array using JQuery

August 4, 2010 | Filed Under JQuery | Comments Off

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.

Comments

Comments are closed.

© PHPInterviewQuestion.com 2009 - 2012

eXTReMe Tracker