checkbox 2 sets.. validations

halo folks

how wud u validate the following
assume a and b are 2 differnt table having a sets of checkbox

table A has 3 check boxes

table B has 10 checkboxes + select ALL check box which wil check/uncheck all the 10 checkboxes

i am generateing all the 10 checkboxes in a LOOP
<%for i= 1 to 10.....<input type=checkbox name=check<%=i%>><%next%>

my validation needed here is of 2 types:

1).if i select ALL in Table B ,i shud be able to choose only one checkbox in Table A

for e.g
 i choose ALL and i choose 1 in Table A.now if i try to check on 2 in table A its shud alert.."oops no multiple checking allowed for this combination"
vice versa must also be true i.e if i chose checkbox 1,3 in table A i shud NOT be able to check ALL in Table B

2).if i select more than 1 check box in Table B ,i shud be able to select only one chekbox in table A

for e.g
if i choose check box 2 and checkbox 7 in table B and i chose checkbox 2 in Table A.now if i try  to check on checkbox 1 in table A its must alert me in same way
it shud be true vice versa also

assume this as a mock template.

A  B
1  1
2  2    
3  3
   4
   5
   6
   7
   8
   9
   10
   ALL


hope i made it clear....
thanks in advance folks
pgnath
pgnathAsked:
Who is Participating?
 
fritz_the_blankConnect With a Mentor Commented:
If you want to add the code to the onClick event for the other boxes, just do it as follows:

<input type=checkbox name=checkbox1 onCick="javascript:countChecks()">

<input type=checkbox name=checkbox1 onCick="javascript:countChecks()">

<input type=checkbox name=checkbox3 onCick="javascript:countChecks()">

Fritz the Blank
0
 
fritz_the_blankCommented:
Okay, so the checkboxes for the B table are check1, check2...check10, but what are the names for the A table checkboxes?

Fritz the Blank
0
 
fritz_the_blankCommented:
Here is part of the code:

iCheckedB =0
for(i=1;i<11;i++){
   if(eval('document.forms[0].check' + i)){
      iCheckedB = iCheckedB +1;
      }
   }

Fritz the Blank
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
pgnathAuthor Commented:
its named as checkbox1,checkbox2,checkbox3
0
 
fritz_the_blankCommented:
function countChecks()
{
iCheckedA = 0
for(i=1;i<4;i++){
  if(eval('document.forms[0].checkbox' + i)){
     iCheckedA = iCheckedA +1;
     }
  }


iCheckedB = 0
for(j=1;j<11;j++){
  if(eval('document.forms[0].check' + j)){
     iCheckedB = iCheckedB +1;
     }
  }

if(iCheckedB >1 && iCheckedA >1){
   alert("If any items in B are checked, you can check only 1 A");
   return false;
}

return true;

}
0
 
pgnathAuthor Commented:
Fritz
wht is the event causing the countchecks() to happen???
thanks
Pgnath
0
 
fritz_the_blankCommented:
When do you want to validate?

<form action="http://www.FairfieldConsulting.com" onSubmit="return countChecks()")

The above will fire the code when one goes to submit the form. If you want it to fire every time someone clicks on a checkbox, then:

<%for i= 1 to 10.....<input type=checkbox name=check<%=i%> onCick="javascript:countChecks()"><%next%>

Fritz the Blank
0
 
pgnathAuthor Commented:
fritz i am not combining the ALL checkbox along with the 10.so will it hold good even for that ALL checkbox???

Pgnath
0
 
pgnathAuthor Commented:
ok lemme try now and wil let u know
0
 
pgnathAuthor Commented:
fritz its not this way
if i select more than 1 checkbox in B then only it shud say "only one check box can be checked in A"

as per ur code its saying that alert even if i select one checkbox in B.

also its giving me that alert even if i am unchecking the checkbox

was my question clear???
pls lemme know
Pgnath
0
 
fritz_the_blankCommented:
You can change the message text to whatever you like. As I understand it, if more than one checkbox in B is selected, you can select only 1 box from A. Is that correct?

Fritz the Blank
0
 
ahosangFinance Systems DeveloperCommented:
This question has been abandoned. I will make a recommendation to the moderators on its resolution in a week or so. I appreciate any comments that would help me to make a recommendation.
 
In the absence of responses, I may recommend DELETE unless it is clear to me that it has value as a PAQ. Silence = you don't care
 
ahosang
0
 
fritz_the_blankCommented:
I feel that I put in the effort here--it is not my fault if pgnath dropped out.

Fritz the Blank
0
 
ahosangFinance Systems DeveloperCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

points to fritz_the_blank
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
ahosang
EE Cleanup Volunteer
0
 
fritz_the_blankCommented:
Thanks.

This didn't really get resolved, but it wasn't clear what pgnath wanted, and s/he bailed.

Fritz the Blank
0
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.

All Courses

From novice to tech pro — start learning today.