PHP, Textareas, and hidden secrets.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

PHP, Textareas, and hidden secrets.

Post 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?!?!?
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post 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.
User avatar
Elmseeker
Forum Contributor
Posts: 132
Joined: Sun Dec 22, 2002 5:48 am
Location: Worcester, MA

Post 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. :)
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Ok thanks guys.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
User avatar
DaZZleD
Forum Commoner
Posts: 38
Joined: Tue Jan 07, 2003 5:39 am

Post 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.
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post 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.
laserlight
Forum Commoner
Posts: 28
Joined: Wed Jan 01, 2003 6:41 am

Post 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.
laserlight
Forum Commoner
Posts: 28
Joined: Wed Jan 01, 2003 6:41 am

Post 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.
User avatar
DaZZleD
Forum Commoner
Posts: 38
Joined: Tue Jan 07, 2003 5:39 am

Post 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.
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

Get your Brains working ya'll...
Good Heavens! Would Henry Higgins approve?

Cheers,
BDKR
User avatar
Elmseeker
Forum Contributor
Posts: 132
Joined: Sun Dec 22, 2002 5:48 am
Location: Worcester, MA

Post 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:
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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:
User avatar
DaZZleD
Forum Commoner
Posts: 38
Joined: Tue Jan 07, 2003 5:39 am

Post 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... :?
User avatar
Elmseeker
Forum Contributor
Posts: 132
Joined: Sun Dec 22, 2002 5:48 am
Location: Worcester, MA

Post 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.
Post Reply