asked on
<script src="../scripts/validateUser.js" language="javascript" type="text/javascript"></script>
<script language="javascript">
$(document).ready(function(){
$("#btn2").bind('click', checkDelete);
});
</script>
<!---this is where my checkboxes are created--->
<cfoutput query="Users">
<tr class="delegatesRows">
<td>#userid#</td>
<td>#lastname#</td>
<td>#firstname#</td>
<td>#type#</td>
<td><input type="checkbox" name="chkDel_#currentrow#" id="chkDel_#currentrow#" value="#userid#" class="chkDel" /></td>
</tr>
</cfoutput>
<!---end user.cfm page--->
<!---validateUser.js file that is loaded at the top after the jquery lib in my user.cfm page--->
<!---this is where I need help to figure out if the user has checked any rows or not. If the user has not checked anything, then they get an alert stating they need to check atleast one checkbox. If they check one or more, then they get a confirmation box asking if they want to proceed--->
var checkDelete = function(){
alert($(".chkDel").attr("id"));
if($(".chkDel")==undefined){
alert("Atleast one entry has to be checked to be deleted!");
return false;
}
if(confirm("Are you sure you want to delete the checked user/s?")){
return true;
}
else{
alert("Delete cancelled!");
return false;
}
}
<!---the above code as it stands does not work--->