Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

checkbox 2 sets.. validations

Posted on 2002-03-12
15
Medium Priority
?
335 Views
Last Modified: 2012-08-14
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
0
Comment
Question by:pgnath
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
  • 2
15 Comments
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 6858019
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 6858027
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
 

Author Comment

by:pgnath
ID: 6858038
its named as checkbox1,checkbox2,checkbox3
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 6858060
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
 

Author Comment

by:pgnath
ID: 6858102
Fritz
wht is the event causing the countchecks() to happen???
thanks
Pgnath
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 6858133
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
 

Author Comment

by:pgnath
ID: 6858272
fritz i am not combining the ALL checkbox along with the 10.so will it hold good even for that ALL checkbox???

Pgnath
0
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 300 total points
ID: 6858289
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
 

Author Comment

by:pgnath
ID: 6858496
ok lemme try now and wil let u know
0
 

Author Comment

by:pgnath
ID: 6858688
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 6858724
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
 
LVL 12

Expert Comment

by:ahosang
ID: 8076158
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 8076338
I feel that I put in the effort here--it is not my fault if pgnath dropped out.

Fritz the Blank
0
 
LVL 12

Expert Comment

by:ahosang
ID: 8234550
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 8234571
Thanks.

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

Fritz the Blank
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question