# How to implement checkbox-like selection with client-side state & controls?

**URL:** <https://www.ruby-forum.com/t/how-to-implement-checkbox-like-selection-with-client-side-state-controls/164918>\
**Category:** Rails\
**Created:** [April 7, 2009, 12:16pm UTC](https://www.ruby-forum.com/t/how-to-implement-checkbox-like-selection-with-client-side-state-controls/164918 "2009-04-07T12:16:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jon-k](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8baadc/32.png) [@jon-k](https://www.ruby-forum.com/u/jon-k)\
**Post date:** [April 7, 2009, 12:16pm UTC](https://www.ruby-forum.com/t/how-to-implement-checkbox-like-selection-with-client-side-state-controls/164918/1 "2009-04-07T12:16:54Z")

</div>

Hi,

This is my first Rails project, and I’ve just hit my first stumbling  
block… I’m looking for some general pointers on how to implement the  
following:

- Allow the user to toggle the selection of words in a given string
- Change the colour appropriately (ideally using CSS class)
- Prevent non-adjacent words from being selected
- Allow the user to submit the current selection

The text needs to read as a sentence, and I want to minimise server  
involvement.

Is there anything in Rails or its plugins to help me out here, or is  
pure Javascript the answer?

cheers,  
Jon
