Halhelms
SIGN UP FOR MY NEWSLETTER

www.savorgold.com is top on wow gold and runescape gold and World of Warcraft gold provider list for trusted services. Their reputation seems to growing by the minute, which isn't surprising because they are one of the safest sellers of Gold. Delivery speed and customer service are very good. They aslo are giving some bonus items depending on the amount of gold you purchase.

 
 
Halhelms

Recent Comments

Recent Entries

RSS

Learning jQuery, Day 14: Checkbox Quick Selection

I'm part of a select group of developers who have access to a secret web app called "Google Mail". Since you, doubtless, are unfamiliar with this software (I did say "select", after all), let me explain how it works.

The application actually lets me send and receive email. And my emails are saved in a table-like format with checkboxes next to each entry. I'm also part of a group of web users selected for our high intelligence to receive special offers through this email thing. Some of them are very valuable (as of this writing, I'm in negotiations with a Dr. Karl Mbutu on a special deal involving a large sum of money garnered from the Nigerian Oil Ministry), but some are less valuable. (If I can get $20 million from Karl, I really don't need Honorable Ashanti Nbektu's paltry $3 million. Sorry, Honorable: you have to step up your game.)

These less valuable offerings, of which I receive my fair share, I'd like to delete. And this secret app lets me do just that -- but not very efficiently. I have to click each entry and then press the "Delete" button. It's not bad when there are only a few checkboxes, but on a page with 20 or 30 of these, it's tedious.

Luckily pour moi, I've been reading a series of blog posts about "Learning jQuery" and have sharpened up my JavaScript and jQuery skills.

Here's my page with checkboxes on it:

<p>Are you...</p>
<table id="mytable">
   <tr>
      <td><input type="checkbox" class="quick_select" name="a" value="a"></td>
      <td>looking to get rich quick?</td>
   </tr>
   
   <tr>
      <td><input type="checkbox" class="quick_select" name="b" value="b"></td>
      <td>have no skills?</td>
   </tr>
   
   <tr>
      <td><input type="checkbox" class="quick_select" name="c" value="c"></td>
      <td>really lazy?</td>
   </tr>
</table>   
<p>No problem! Download our "Guide to Getting Rich Quick For People Who Are Really Lazy But Have No Discernible Skills"</p>

<cfinclude template="index.pgm">

And here's my kewl new "index.pgm" page:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
   /* get the elements that have a class name of "quick_select"*/
   $( '.quick_select' )
      /* when someone mouses over one of these elements...*/
      .mouseover( function()
         {
            /* turn the unchecked boxes ON and the checked boxes OFF */
            $cb = $(this);    
            $cb.attr( 'checked', !($cb.attr( 'checked' )));
         };
      );
</script>

Mad skillz, undoubtedly. And surely worth a lot. And yet I'm giving this away free. Why? Well, with the 20 mill from the good doctor, it's just my way of "giving back".

I'll be in Tahiti if you need me.

Zipped files

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Raymond Camden's Gravatar What we really need is a jQuery plugin to simply detect spam. Get on that please. It shouldn't take you more than a few minutes.
# Posted By Raymond Camden | 6/14/09 11:10 AM
Hal's Gravatar Spam? Is that any way to speak of the generous offers made by selfless philanthropists?
# Posted By Hal | 6/14/09 12:26 PM
Will Wilson's Gravatar If that was in google mail it would drive me crazy! What if you're deleting and on your way to click the delete button you hover over some important emails? I think a 'select all' approach is much better, then you can just uncheck those you need (if there is so much spam on that page).

Still, its quite cool to see them all select/deselect when you drag your mouse over. Just don't think it's very practical
# Posted By Will Wilson | 6/14/09 1:07 PM
Hal's Gravatar Will,

I would welcome that ability. The hovering action could be limited to just the checkboxes. Or you could, alternately, change the action so that only if the SHIFT key were pressed would that rapid select be enabled. For me, the hassle of clicking ALL, then deselecting (which is what I have to do now) means that I don't clean my email to the degree I wish I did.
# Posted By Hal | 6/14/09 1:25 PM
Will Wilson's Gravatar ooo, I like the idea of the shift key, or similarly a button that you press to activate it for those visual UI people. I still don't like the idea of having it enabled by default, even on just the checkbox. I'm sure there would be plenty of people that wouldn't realise and have a WTF moment when they can't find an email
# Posted By Will Wilson | 6/14/09 3:54 PM
Steve's Gravatar Great idea, I think that I can put it to good use. However, it would have been nice if you would have said something about the SHIFT key being a trigger of sorts. I almost gave up but worked my way through the pgm file and noticed the bit about the shift key. I guess that I didn't expect the test. Thanks again.
# Posted By Steve | 6/16/09 12:48 PM
glenn's Gravatar Thanks for the info. I am interested in a way to remove checkboxes on my page using jquery. My checkboxes are formed from a cookie and i have been able to add more checkboxes (add an array element to the cookie) but haven't figured out how i can delete the array element if a user clicks on the checkbox name. I am thinking that i must rebuild the cookie when someone wants to remove a check box from it. Any other suggestions?

Glenn
# Posted By glenn | 9/14/09 4:35 PM
 
   
Clicky Web Analytics