• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

select and unselecting checkboxes based on clicking a check box

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a check box name "select" and and also some four check boxes named as "child". when i click or check the "select" check box all the child check box has to be checked and when i unselect or uncheck the "select" box ,all the child check boxes has to be unchecked. I have done this task using javascript. My problem is that when i uncheck atleast a "child" checkbox automatically the "select" check box has to be unselected. How can i do this using javascript?If there is any example available kindly publish here.
 
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when click of select checkbox you calling JS function in that you are checking all child checkboxes I guess.

same way when you click on any child checkbox call another JS function in that get all child checkbox & check if any one of them is unchecked then uncheck select checkbox.

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
how about writing one generic function which handles all the checkboxes? say you have a javascript method called
handleCheckBoxes(key) and you pass "this", that is, the reference to that box on whose selection you are calling the method.
Now, inside the method, its simply writing the conditions and selecting or unselecting the boxes, right?
 
shyamkumar bopannachengalaiah
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Shail Narkhede wrote:when click of select checkbox you calling JS function in that you are checking all child checkboxes I guess.

same way when you click on any child checkbox call another JS function in that get all child checkbox & check if any one of them is unchecked then uncheck select checkbox.



Is there any examples available?
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Searching the forum might be a good start: https://coderanch.com/forums/jforum?module=search&action=search&forum=20&match_type=all&sort_by=time&search_keywords=Check+All+Checkboxes

Eric
 
reply
    Bookmark Topic Watch Topic
  • New Topic