Meps
asked on
Please help with validation
Here is what I want. I have 4 groups of check boxes and text boxes, and when one group is selected it disables the remaining groups.
Here is my problem. They are all dymanic from a cfloops.
Here is a example of what I am talking about
<CFSET rowcount = 1>
<CFLOOP QUERY="group 1">
<TR>
<TD><INPUT TYPE="checkbox" NAME="check#rowcount#" VALUE=""></TD>
<TD><INPUT TYPE="text" NAME="text#rowcount#"></TD >
</TR>
<CFSET rowcount = rowcount + 1>
</CFLOOP>
<CFLOOP QUERY="group 2">
<TR>
<TD><INPUT TYPE="checkbox" NAME="check#rowcount#" VALUE=""></TD>
<TD><INPUT TYPE="text" NAME="text#rowcount#"></TD >
</TR>
<CFSET rowcount = rowcount + 1>
</CFLOOP>
<CFLOOP QUERY="group 3">
<TR>
<TD><INPUT TYPE="checkbox" NAME="check#rowcount#" VALUE=""></TD>
<TD><INPUT TYPE="text" NAME="text#rowcount#"></TD >
</TR>
<CFSET rowcount = rowcount + 1>
</CFLOOP>
<CFLOOP QUERY="group 4">
<TR>
<TD><INPUT TYPE="checkbox" NAME="check#rowcount#" VALUE=""></TD>
<TD><INPUT TYPE="text" NAME="text#rowcount#"></TD >
</TR>
<CFSET rowcount = rowcount + 1>
</CFLOOP>
The names of the checkboxs are pretty much all the same except for their row number. But I want to issolate one group and only that one group, and when someone clicks within the group I want to disable the the other groups. Now here is when it gets ugly, I have no control over the rowcounts, like one day there will be 21 items in group 1, then the next day there could be 15, so the validation can't use any static numbers.
I know I just need to add a onclick to the group I wish to use, btw it is group 2. But does anyone have any ideas?
Here is my problem. They are all dymanic from a cfloops.
Here is a example of what I am talking about
<CFSET rowcount = 1>
<CFLOOP QUERY="group 1">
<TR>
<TD><INPUT TYPE="checkbox" NAME="check#rowcount#" VALUE=""></TD>
<TD><INPUT TYPE="text" NAME="text#rowcount#"></TD
</TR>
<CFSET rowcount = rowcount + 1>
</CFLOOP>
<CFLOOP QUERY="group 2">
<TR>
<TD><INPUT TYPE="checkbox" NAME="check#rowcount#" VALUE=""></TD>
<TD><INPUT TYPE="text" NAME="text#rowcount#"></TD
</TR>
<CFSET rowcount = rowcount + 1>
</CFLOOP>
<CFLOOP QUERY="group 3">
<TR>
<TD><INPUT TYPE="checkbox" NAME="check#rowcount#" VALUE=""></TD>
<TD><INPUT TYPE="text" NAME="text#rowcount#"></TD
</TR>
<CFSET rowcount = rowcount + 1>
</CFLOOP>
<CFLOOP QUERY="group 4">
<TR>
<TD><INPUT TYPE="checkbox" NAME="check#rowcount#" VALUE=""></TD>
<TD><INPUT TYPE="text" NAME="text#rowcount#"></TD
</TR>
<CFSET rowcount = rowcount + 1>
</CFLOOP>
The names of the checkboxs are pretty much all the same except for their row number. But I want to issolate one group and only that one group, and when someone clicks within the group I want to disable the the other groups. Now here is when it gets ugly, I have no control over the rowcounts, like one day there will be 21 items in group 1, then the next day there could be 15, so the validation can't use any static numbers.
I know I just need to add a onclick to the group I wish to use, btw it is group 2. But does anyone have any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
also there is an extra } above the else statement, take it out
ASKER
That works, but it also disables my submit buttons I have a "back", "reset", and "next" buttons.
ASKER
I think I fixed the problem with the submit buttons, and had forgotten about a hidden field I needed enabled.
function DisableGroups( objTargetCheckBox ){
// Variables
var blnChecked = objTargetCheckBox.checked;
var intIndex = 0;
// Do we disable or enable?
if( blnChecked == true ){
// Disable
for( intIndex = 0; intIndex < document.formName.elements .length; intIndex++ ){
// Is this our checkbox?
if( document.formName.elements [ intIndex ].name == objTargetCheckBox.name ){
// Yes, dont disable this or the next element ( the text box )
intIndex++;
}
else{
if( document.formName.elements [ intIndex ].name != "System_Record"){
if( document.formName.elements [ intIndex ].name != "GoBack"){
if( document.formName.elements [ intIndex ].name != "GoNext"){
if( document.formName.elements [ intIndex ].name != "Reset"){
// No, disable
document.formName.elements [ intIndex ].disabled = true;
}
}
}
}
}
}
}
else{
// Enable, loop through all controls and enable them
for( intIndex = 0; intIndex < document.formName.elements .length; intIndex++ ){
// Enable this form element
document.formName.elements [ intIndex ].disabled = false;
}
}
}
function DisableGroups( objTargetCheckBox ){
// Variables
var blnChecked = objTargetCheckBox.checked;
var intIndex = 0;
// Do we disable or enable?
if( blnChecked == true ){
// Disable
for( intIndex = 0; intIndex < document.formName.elements
// Is this our checkbox?
if( document.formName.elements
// Yes, dont disable this or the next element ( the text box )
intIndex++;
}
else{
if( document.formName.elements
if( document.formName.elements
if( document.formName.elements
if( document.formName.elements
// No, disable
document.formName.elements
}
}
}
}
}
}
}
else{
// Enable, loop through all controls and enable them
for( intIndex = 0; intIndex < document.formName.elements
// Enable this form element
document.formName.elements
}
}
}
ASKER
Thanks for your help.
onclick="DisableGroups( this );"