Friday, February 27, 2009

using jquery to create check box for each item

if you want to create a check box each of the item with toggle functionality use this code snippet

<script type="text/javascript">
$(document).ready(function() {

$("#<%=btnSendEnquiryList.ClientID%>").click(function(event) {
var hasItemSelected = false;
$("#<%=dlNewDev.ClientID%> :checkbox").attr("checked", function() {
if ($(this).attr("checked") == true) {
hasItemSelected = true;
$(this).preventDefault();
} else {
hasItemSelected = false;
}
});


if (hasItemSelected == false) {
alert("There is no listing selected. Please select at least 1 listing.");
return false;
}
});

$("#<%=chkCheckedAll.ClientID%>").click(function() {
$("#<%=dlNewDev.ClientID%> :checkbox").attr("checked", function() {
if ($(this).attr("checked") != true) {
$(this).attr("checked", "checked")
} else {
$(this).removeAttr("checked")
}
});

});

});
</script>

2 comments:

Anonymous said...

I’ve been visiting your blog for a while now and I always find a gem in your new posts. Thanks for sharing.

Anonymous said...

Ні thеre, I ԁiscοѵered уоur web site by means оf Google аt
thе ѕamе time as searchіng foг a
simіlar mattеr, уоur sitе came uр, it lοοκs good.
І've bookmarked it in my google bookmarks.
I'm not sure the placе уоu're getting your info, however good topic. I must spend some time learning more or understanding more. Thanks for great information I was in search of this info for my mission.

My homepage :: payday loans