Page 1 of 2

PHP, Textareas, and hidden secrets.

Posted: Thu Jan 09, 2003 5:15 pm
by Gen-ik
Does anyone know of a way to change the colour (or 'color' for our American friends out there) of certain parts of text in an HTML textarea created from PHP?

Here's an example of what I'm going on about..

Code: Select all

<?php

echo("<textarea type=text cols=100 rows=10>");

echo(stripslashes($this_text));

echo("</textarea>");

?>
I'm just wondering if there is a 'hidden' way of doing it just like new lines in the textarea are created with the 'hidden' \n tag.

Get your Brains working ya'll :D



Oh by the way where the hell has the PHP BBcode button gone?!?!?

Posted: Thu Jan 09, 2003 5:21 pm
by mydimension
you can't. you might try looking though for a javascript/javaApplet/ActiveX application that you could plug into your page and that might allow you to something like that.

about the php button, not sure. jason may be doing some redesigning of the site. we'll see.

Posted: Thu Jan 09, 2003 6:09 pm
by Elmseeker
The color changing thing can be done, it won't change the color in the input box itself but on the output, not sure how though...str_replace() maybe?. And I was talking to jason earlier today and he is indeed changing the phpBB system around, upgrading to a newer version...Have fun. :)

Posted: Thu Jan 09, 2003 6:11 pm
by Gen-ik
Ok thanks guys.

Posted: Thu Jan 09, 2003 8:29 pm
by volka
Powered by phpBB 2.0.3 © 2001
It's a new version and Jason didn't put in the

Code: Select all

-tag again by now

Posted: Fri Jan 10, 2003 3:45 am
by DaZZleD
you CAN change the colour of the text in a textarea or textfield with css styles. example:

Code: Select all

<html>
<head>
<style type='text/css'>
textarea&#123;                           //this is to change ALL textareas' attributes
  font-family: 'Times New Roman", Times, serif;
  font-size: 10px;
  text-transform: capitalize;
  color: #0099ff;
  text-decoration: line-through;
  background-color: #00FFFF;
&#125;
</style>
</head>
<body>
</body>
</html>

Code: Select all

<html>
<head>
<style type='text/css'>
.myownstyle    // you need to add class='.myownstyle' to all textareas to which you want to apply this style (ofc you might want to make multiple styles, one for each textarea)
&#123;
  font-family: 'Times New Roman", Times, serif;
  font-size: 10px;
  text-transform: capitalize;
  color: #0099ff;
  text-decoration: line-through;
  background-color: #00FFFF;
&#125;
</style>
</head>
<body>
<textarea name='whatever' class='.myownstyle'></textarea>
</body>
</html>
i gave you some of the available options though they are not all that you can configure for a textarea. consult a css manual for more details.

Posted: Fri Jan 10, 2003 3:57 am
by Gen-ik
I'm actually just wanting to change just part of the text in a textfield, not all of it... and I know CSS.

Thanks anyway.

Posted: Fri Jan 10, 2003 4:03 am
by laserlight
I suppose if you want to include styles on the fly with PHP you could always parse the textarea tag to write in a style attribute, or write the class attribute.

btw DaZZleD, I think that class=".myownclass" should be class="myownstyle", the dot is to differentiate between tags and classes when declaring, not when using.

Posted: Fri Jan 10, 2003 4:06 am
by laserlight
I'm actually just wanting to change just part of the text in a textfield
maybe try some sort of fixed length <div> tag for an effect like a textarea?
I dont think one can do it with PHP and textareas.

Posted: Fri Jan 10, 2003 8:43 am
by DaZZleD
laserlight wrote:btw DaZZleD, I think that class=".myownclass" should be class="myownstyle", the dot is to differentiate between tags and classes when declaring, not when using.
it was a typo...

to answer the question, you cannot change just a part of the textarea text. it's either all or none.

Posted: Fri Jan 10, 2003 9:19 am
by BDKR
Get your Brains working ya'll...
Good Heavens! Would Henry Higgins approve?

Cheers,
BDKR

Posted: Fri Jan 10, 2003 9:29 am
by Elmseeker
BDKR wrote:
Get your Brains working ya'll...
Good Heavens! Would Henry Higgins approve?

Cheers,
BDKR
Be assured that he would definately NOT approve...but then again he always was a bit of a snob about proper english. :twisted:

Posted: Fri Jan 10, 2003 9:29 am
by volka
But all I want is 'enry 'iggins 'ead!"
"Done," says the King with a stroke.
"Guard, run and bring in the bloke!
Then they'll march you, 'enry 'iggins to the wall;
And the King will tell me: "Liza, sound the call."
As they lift their rifles higher, I'll shout:
"Ready! Aim! Fire!"
Oh ho ho, 'enry 'iggins,
Down you'll go, 'enry 'iggins!
Just you wait!
:twisted:

Posted: Fri Jan 10, 2003 9:45 am
by DaZZleD
laserlight wrote: maybe try some sort of fixed length <div> tag for an effect like a textarea?
I dont think one can do it with PHP and textareas.
you cannot use divs to get user input... to display something, yes, not to get it though... :?

Posted: Fri Jan 10, 2003 9:50 am
by Elmseeker
volka wrote:But all I want is 'enry 'iggins 'ead!"
"Done," says the King with a stroke.
"Guard, run and bring in the bloke!
Then they'll march you, 'enry 'iggins to the wall;
And the King will tell me: "Liza, sound the call."
As they lift their rifles higher, I'll shout:
"Ready! Aim! Fire!"
Oh ho ho, 'enry 'iggins,
Down you'll go, 'enry 'iggins!
Just you wait! :twisted:
Yeah, and 10 minutes later she changes her tune to:

"I could have danced all night."
"I could have danced all night, and still have begged for more."
"I could have spread my wings and done a thousand things,"
"I've never done before."
:roll:
Just proving once again that people aren't very stable to begin with.