ShiftClick to select a range of check boxes
Smits
3 posts
|
Dear Christophe, My question is how to make a routine to check a range of check boxes in a form using a click (for the first) and a shift-click (for the last). My search lead to a JQuery plugin page of John Sutherland named jquery.shiftclick We have a form on our page (id=frmStudentList) with a table containing a check box in front of each name in the table rows. The check boxes have a class checkbox. There are only check boxes, no other input fields. We don’t want to attach listeners to each checkbox (because the table will be updated by an Ajax call), so there is just one statement: Here is the code:
Can you comment on this code.Is there a way to do this faster or better with either Prototype or Script.aculo.us? Thanks for your answer. Kind regards from the Netherlands, |
Christophe P...
48 posts
|
Hey Johan, No time to reply just now, but the problem is interesting and I think I see a simple solution. Ping me by email tomorrow and I’ll try to come up with something here. Cheers, |
Smits
3 posts
|
Hey Christophe, I’m sorry but I don’t have your mail address so I can’t ping. Nice to see that this problem interests you. It is, I think, worthwhile to discuss because this will give users a better UI. In the meantime I will wait for your comment. Warm regards, |
Christophe P...
48 posts
|
Hey Johan, Well your implementation works alright. It makes little use of “comfort methods” so it’s pretty fast as it is. I have a few remarks, however:
So I might rephrase your function like this:
There are several tricks we could use to size it down a little, but they’d be somewhat detrimental to speed, so the trade-off isn’t so good. ‘HTH |
Smits
3 posts
|
Hi Christophe, Thanks for your post and your remarks. Allow me to comment some of them. 1. I forgot to write in my origin post, but I declared 2. Those checks are from an other try at another topic. They must be left out. 3. You are right that inverting conditions and using 4. With respect to (My background is not Delphi, although I learned programming in Pascal, from a book of Niklaus Wirth, Algorithms+DataStructures=Programs. Later I learned SPSS, Visual Basic, dBASE, SQL, mySQL, PHP4 and 5, CSS from the Eric Meyer books and unobtrusive Javascript from Stuart Langridge and PPK. Since it is important to know what kind of object or type you have in your variable I am using the Hungarian naming convention, so all my string variables are prepended with str, objects with obj, arrays with arr and so on. Although your variable names are a little longer it gives you a very good view what to expect in a certain variable. In the html context I always have forms with (names and) ids like frm…, tables with id tbl.. and so on) The only exception I make is to use i for an integer index, instead of the full index as you did. In your code you have to adjust that Thanks again for your comments and I hope you will enjoy Boston, at the end of September. Warm regards from the Netherlands, |
5 posts, 2 voices
