I have a text box that I tyoe text into and a script writes that text to a text file. I then have that server side included into an html page.
I currently have the html page <PRE></PRE> formatting the included text so that it will recognize hard returns entered into the text using my php text entry page. But this creates very ugly text.
Is there a better way to do this?
How do I change the font and color of text created by script
Moderators: egami, macek, gesf
- Joan Garnet
- Moderator
- Posts: 387
- Joined: Sat Aug 03, 2002 2:56 am
- Location: Mars
- Contact:
Using html tags when creating the text will work just fine.
If not, use javascript to insert tags when pressing ENTER.
You've got the onKeyPress event.

If not, use javascript to insert tags when pressing ENTER.
You've got the onKeyPress event.

you can also try using the nl2br function to convert new lines in the text into <BR> tags. I've used this a bit, and I love it. Whenever the function hits a new line, i.e. carriage return or linefeed, it inserts a <BR> tag. very handy.
Joan Garnet wrote:Using html tags when creating the text will work just fine.
If not, use javascript to insert tags when pressing ENTER.
You've got the onKeyPress event.
can you give me an example of how to use the onkeypress event? That may be the way I want to go.
Is there a way to limit number of characters per line, change font, size/color/font?
- Joan Garnet
- Moderator
- Posts: 387
- Joined: Sat Aug 03, 2002 2:56 am
- Location: Mars
- Contact:
Here you are an example -->
It works for both ns4+ and ie4+
bye!

Code: Select all
<FORM action="<?php $PHP_SELF ?>" method="post">
<P>
<TEXTAREA name="my_textarea" rows="20" cols="80" style="font-size: 12pt; color: gray" title="My TEXTAREA" ONKEYDOWN="javascript: IE = (document.all) ? 1 : 0; keyChar = IE ? event.keyCode : ev.which; keyChar==13? document.forms[0].my_textarea.value += '<br>' : null; ">
This is a textarea.
This is php-forum.
</TEXTAREA>
<INPUT type="submit" value="Send" onClick="javascript: var max_char=10; if(document.forms[0].my_textarea.value.length>max_char){alert('Too Many Characters Entered');return false;}else{return true;} "> <INPUT type="reset">
</P>
</FORM>
It works for both ns4+ and ie4+
bye!
