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

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