Uncategorized

check and uncheck checkboxes using two links in a drop down

Hi guys, when i needed to check and uncheck a number of check-boxes on my page, as in the demo, at http://jsfiddle.net/FvKZW/5/ i had to write that simple working example, i thought it can be important to some one else so i have decided to share this via this post.

This is the jQuery:

var jq = jQuery;
jq('#selectAll_categories').click(function (event) {
    console.log(jq('.category_check'));
    jq('.category_check').prop('checked', true);
    return false;
});


jq('#deselectAll_categories').click(function (event) {
    jq('.category_check').prop('checked', false);
    return false;
});

and here is some html;

<a href="#" id="selectAll_categories">Select All</a>&nbsp&nbsp&nbsp&nbsp<a href="#" id="deselectAll_categories">Deselect All</a>
						
										<br /><hr />
<input class="category_check" type="checkbox" name="diagnoses">Diagnoses <a href="#">(1)</a>

<br />
<input class="category_check" type="checkbox" name="labs">Labs <a href="#">(121)</a>
</br>
<input class="category_check" type="checkbox" name="meds">Meds <a href="#">(103)</a>

<br />
<input class="category_check" type="checkbox" name="orders">Orders <a href="#">(1002)</a>

<br />
<input class="category_check" type="checkbox" name="reports">Reports <a href="#">(198)</a>

<br />
<input class="category_check" type="checkbox" name="vitals">Vitals <a href="#">(12)</a>

<br />
    <input class="category_check" type="checkbox" name="others">Others <a href="#">(34)</a><br /><hr />

Please let me know if this has been helpful to you?

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s