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?
LVL 3
MepsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

justinbilligCommented:
this is pretty easy,


do something like this

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
                  {
                        // 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;
            }
      }
}
            




replace formname with the name of your form
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
justinbilligCommented:
oh yeah and in each of your checkboxes put this


onclick="DisableGroups( this );"
0
justinbilligCommented:
also there is an extra } above the else statement, take it out
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

MepsAuthor Commented:
That works, but it also disables my submit buttons I have a "back", "reset", and "next" buttons.
0
MepsAuthor Commented:
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;
         }
    }
}
0
MepsAuthor Commented:
Thanks for your help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.