Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: COLOR of textarea

by liverpole (Monsignor)
on Nov 14, 2011 at 18:10 UTC ( #937998=note: print w/replies, xml ) Need Help??

in reply to COLOR of textarea

Hi tarunkhanna,

As other have noted, this hasn't anything to do with perl.

But since you're pretty close, try doing this:

#!/usr/bin/perl -w use strict; use warnings; use CGI; my $co = new CGI; my $color = 'red'; print $co->header; print $co->start_html(); print $co->start_form; print $co->radio_group( -name => 'color', -id => 'color', -values => ['red','yellow','green'], -default => 'red', -onClick => "return select_color(this)" ).$co->p; print $co->textarea( -id => "textarea", -style=> "background-color:$color; color:blue", ); print $co->end_form; print $co->end_html; print <<COLOR_SCRIPT; <script language="JavaScript"> function select_color(rb_obj) { var color = rb_obj.value; var ta_obj = document.getElementById('textarea'); = color; return color; } </script> COLOR_SCRIPT

Note that it passes "this" to the function select_color, so that the value will change with the color. The id of the text_area object is then looked up, and its style.background is assigned to the current color.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://937998]
[chacham]: there's a regexp function. if that can be used ina check() constraint...
[LanX]: Thanks, but no check constraints in MySQL :/
LanX 1 ..2 ..3 ..4 .. is erix missing ;-)
LanX is Discipulus reciting "Springtime for Hitler" ?
[choroba]: erix could tell you how to do it in Postgres
[chacham]: wow, mysql really is as bad as i thougt
[choroba]: completion?
[LanX]: That's what he usually does when MySQL is mentioned ;-)

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (11)
As of 2017-03-30 15:06 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (360 votes). Check out past polls.