|
-
Validate dynamically named checkboxes
Hi All, I'm trying to validate that at least 1 checkbox is checked on a page: This is my code for the checkboxes:
<cfloop query="getprojects">
<tr>
<td bgcolor="##CCCCCC"><input type="checkbox" name="f_project_#project_name_id#" value="#project_name_id#" id="f_project_#project_name_id#" onClick="javascript:enableField_#project_name_id#()">#project_name#</td>
<td bgcolor="##CCCCCC"><input name="f_support_#project_name_id#" type="radio" value="1" id="f_support_#project_name_id#" disabled></td>
<td bgcolor="##CCCCCC"><input name="f_support_#project_name_id#" type="radio" value="0" id="f_support_#project_name_id#" disabled></td>
<td bgcolor="##CCCCCC"><input name="f_support_#project_name_id#" type="radio" value="2" id="f_support_#project_name_id#" checked disabled></td>
</tr>
</cfloop>
I have the following javascript to try to validate:
script language="JavaScript" type="text/JavaScript">
function validate() {
//check a field to make sure it has something filled in
count = 0;
<cfloop query="getprojects">
for(x=0; x<document.stakeholder.f_project_<cfoutput>#project_name_id#</cfoutput>.length; x++){
if(document.stakeholder.f_project_<cfoutput>#project_name_id#</cfoutput>[x].checked==true){
count++
}
}
</cfloop>
if(count==0){
alert("Select a project");
return false;
}
</script>
Can anyone help me out????????
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
|
Bookmarks