How do I change the font and color of text created by script

General discussions related to php

Moderators: macek, egami, gesf

ckwall

How do I change the font and color of text created by script

Postby ckwall » Mon Jan 06, 2003 8:04 pm

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?

User avatar
Joan Garnet
Moderator
Moderator
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars
Contact:

Postby Joan Garnet » Tue Jan 07, 2003 3:56 pm

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.

:)

ckwall

Postby ckwall » Tue Jan 07, 2003 3:58 pm

I must be doing something wrong then. It just types out my tags in the text.

Hurkle
New php-forum User
New php-forum User
Posts: 36
Joined: Tue Jan 07, 2003 8:45 am
Location: Minnesota, USA

Postby Hurkle » Tue Jan 07, 2003 4:03 pm

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.

ckwall

Postby ckwall » Tue Jan 07, 2003 4:05 pm

Could you provide a sample of how to use this?

ckwall

Postby ckwall » Tue Jan 07, 2003 4:08 pm

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?

User avatar
Joan Garnet
Moderator
Moderator
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars
Contact:

Postby Joan Garnet » Wed Jan 08, 2003 1:53 am

Here you are an example -->

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;} ">&nbsp;<INPUT type="reset">
   </P>
</FORM>


It works for both ns4+ and ie4+
bye!
:)

ckwall

Postby ckwall » Wed Jan 08, 2003 10:39 am

That worked very nicely, Thank you.


Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 1 guest

cron