Hey, I am wondering how to get the id of a checkbox when it is checked.
This is what my HTML would probably look like at first:
<div class="check_filter">
<div id="filter">
<input type="checkbox" id="check1" /><label for="check1">Marketing</label>
<input type="checkbox" id="check2" /><label for="check2">Automotive</label>
<input type="checkbox" id="check3" /><label for="check3">Sports</label>
</div>
</div><!-- End check_filter -->
I'm assuming the jQuery would look something like this:
$(document).ready(function() {
$(":checkbox").click(function(){
var id = $(this).attr('id');
$.post("index.php", { id: id });
//return false to ensure the page doesn't refresh
return false;
});
});
I'm trying to get the checked item id and then post that id in a mysql query to grab the results of the id from the database.
Thanks for any help on this.