Avatar of roger v
roger v
Flag for United States of America

asked on 

jQuery validation in Coldfusion page - question

Hi,

I have a coldfusion 9 page where I'm using jquery for validating user input. I'm having trouble coming up with the exact syntax since I've got checkbox elements that are being dynamically named using the CurrentRow value. My code is attached. TIA
<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--->

Open in new window

ColdFusion LanguageJavaScript

Avatar of undefined
Last Comment
devilJinKazama

8/22/2022 - Mon