HighDots Forums  

Change Text Colour depending on what is written

JavaScript discussion (multi-lingual) JavaScript discussion (alt.comp.lang.javascript)


Discuss Change Text Colour depending on what is written in the JavaScript discussion (multi-lingual) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Steven Sinfield
 
Posts: n/a

Default Change Text Colour depending on what is written - 11-01-2005 , 01:20 AM






Hi There,

I am so not good at javascripts and I'm not even sure if this can be done.

I use PHP and MySql the data that is returned to the browser is taken
directly from the MySQL database, I was looking for some simple solution
where I can have a javascript read what is displayed and change the colour
of that field.

ie. if it says Pending = Red, Approved = Red, Waiting = Blue etc.

Can this be done?



Reply With Quote
  #2  
Old   
Jasen Betts
 
Posts: n/a

Default Re: Change Text Colour depending on what is written - 11-02-2005 , 02:02 AM






On 2005-11-01, Steven Sinfield <ssinfiel (AT) tpg (DOT) com.au> wrote:
Quote:
Hi There,

I am so not good at javascripts and I'm not even sure if this can be done.

I use PHP and MySql the data that is returned to the browser is taken
directly from the MySQL database, I was looking for some simple solution
where I can have a javascript read what is displayed and change the colour
of that field.

ie. if it says Pending = Red, Approved = Red, Waiting = Blue etc.

Can this be done?
yes, but it's probably easier to do it using PHP to give the html fragment the
style tag for the apropriate coloour.

--

Bye.
Jasen


Reply With Quote
  #3  
Old   
Kimmo Laine
 
Posts: n/a

Default Re: Change Text Colour depending on what is written - 11-02-2005 , 06:30 AM



"Steven Sinfield" <ssinfiel (AT) tpg (DOT) com.au> wrote

Quote:
Hi There,

I am so not good at javascripts and I'm not even sure if this can be
done.

I use PHP and MySql the data that is returned to the browser is taken
directly from the MySQL database, I was looking for some simple solution
where I can have a javascript read what is displayed and change the colour
of that field.

ie. if it says Pending = Red, Approved = Red, Waiting = Blue etc.

Can this be done?
In _theory_ something as simple as a stylesheet would work:

<style type="text/css">
input[value="wating"] {
color:green;
background-color:#CCFFCC;
}
input[value="pending"] {
color:red;
background-color:#FFCCCC;
}
</style>

<body>
<input name="" type="text" value="wating" />
<input name="" type="text" value="pending" />
</body>

But sadly IE doesn't support the [attribute="value"] selector standard. In
Opera and Firefox it worked just okay. If you don't need IE-compilant
solution then you can use this.

--
Welcome to Usenet! Please leave tolerance, understanding
and intelligence at the door. They aren't welcome here.
antaatulla.sikanautaa (AT) gmail (DOT) com.NOSPAM.invalid




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.