Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello all,
how to validate checkbox using multiple sub categories?

see this demo...
http://jsfiddle.net/B2nmy/13/[^]

I need a result of when i click Tamilnadu then India and world will be checked..
if i declare india as class=parent then when i click america, india also checked but it was wrong. So how can i rewrite the code to get my needed result?

Kindly help me..
Thanks in advance..
Posted
Comments
Sergey Alexandrovich Kryukov 22-Apr-14 12:37pm    
Here is my statement: a set of check boxes requiring validation is a sign of wrong UI design, its logic.
I must add: not always.
If you can clearly explain your ultimate goal, probably I would be able to explain why and what else could be done.
—SA
sivamzcet 22-Apr-14 12:50pm    
see the demo dude.. i mentioned there is just an example.. Original data was different..
Tamilnadu is in India then India is in the world..
So if i click tamilnadu then both india and world should be checked automatically.. solve this give me a solution

1 solution

Please see my comment to the question.

For now, when I still don't know your goal, try to ask yourself one question: shouldn't the check boxes representing countries be radio buttons?

—SA
 
Share this answer
 
Comments
sivamzcet 22-Apr-14 12:48pm    
no no.. its mainly for sub-categories... when i click any one of the child then the checkboxes parent and grandparent should be checked automatically.. this is i need? can u able to solve it?
Sergey Alexandrovich Kryukov 22-Apr-14 13:28pm    
Explain your purpose from the application standpoint, only then we can discuss it.
—SA
sivamzcet 22-Apr-14 13:57pm    
i need for a tourism management..
the user have to check what are all the places they have visited.. for that only i need..
for ex: i the user visited tajmahal in india then in UI we provide
<checkbox>Country name [say India]
<checkbox>State name [say Delhi]
<checkbox>City name [say Agra]
<checkbox>Tourist place [say Tajmahal]
here if the user visited Tajmahal then he must select All the checkbox. i.e he is able to check 4 times.
But what i need is if the user selects Tajmahal then his parent classes also should be selected automatically. now the times saves here coz the user selects all the checkboxes using single click.
got my point??
Sergey Alexandrovich Kryukov 22-Apr-14 15:55pm    
Thank you for clarification. It makes it even more apparent that the design is wrong.
The idea is: if India is not checked, all of the Indian details should be hidden, if some Indian state is not checked, all the detail related to this state should be hidden, and so on.
As soon as you feel a need in validation, consider UI design is wrong.

Your criteria for UI design should include this: no validation. At the same time, say, text box content usually should be validated, excluding the cases when any text can be considered as valid. You can also filter out some characters.

—SA
sivamzcet 22-Apr-14 22:11pm    
okay i got u..
now i'm not need to validate just simply need to reduce the no.of clicks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900