in reply to COLOR of textarea

Yes, indeed.   Anything that happens “in response to a user-interface action on the user side” always is handled by JavaScript ... on the user side.   (The server does not become involved at all, unless the JavaScript initiates an AJAX request.)

The best-all-around way to handle appearance changes like this, in my humble opinion, is with CSS styles.   Your JavaScript code can query the object to determine which style it currently uses, remove that style and add the “next” one.   This allows you to change many characteristics of the object at one time and to do so consistently throughout.   There are plenty of examples on the Web on how to do this, and none of them involve Perl.