• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Select All

 
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I'm trying to implement a select all functionality i.e if I select a checkbox, a set of other checkboxes must be checked.
The name of check boxes will be like chk1,chk2,chk3...chk22....



I need a pattern for chk.Can it be done?

Thanks all,
Srikkanth.M
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One solution would be to use eva l:



Note that "eva l" must be written as a single word, but the forum software won't allow it

Another solution would be to use a framework that will make it easier for you. For instance, using jQuery you can achieve this in just a few lines:



This code basically means:
when the checkbox with id checkAll is clicked, take all the other checkboxes whose name attribute starts with "chk" and set their "checked" attribute only if checkAll is checked (i.e., this refers to checkAll within the click event handler).
[ August 17, 2007: Message edited by: Valentin Crettaz ]
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
eval = EWWWWWWW! Forget that exits unless you are working with JSON!




another thing you can do is something like this



[I wrote the code here without testing]

Eric
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
eval = EWWWWWWW!

Wasn't very clever from me, I admit
TGIF !!
[ August 17, 2007: Message edited by: Valentin Crettaz ]
 
Alas, poor Yorick, he knew this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic