<input> with large text blocks

HTML, CSS and anything else that deals with client side capabilities.

Moderator: General Moderators

Post Reply
dreeves
Forum Commoner
Posts: 39
Joined: Thu Oct 22, 2009 8:53 am

<input> with large text blocks

Post by dreeves »

I have created a update form (with tables) that displays all the information from a record in a database. In one particular field, the value may be a large amount of text (that I hope can be formatted later). The problem is with the size of the input box. I would like it to remain 4 columns wide, but expand downward (height) to fit the text. I do not want to set the style to be a certain width and height, because there may be more text than can fit in that box.

Also, I would like for my database (mysql) to be able to store the format of the text. I know it has something to do with <pre> but I can not figure out how to use it correctly. Here is the code:

Code: Select all

<TR>
<TH>Comments</TH> // one column wide
<TD><input type="text" name="ud_comments" value="<?php echo $comments;?>"/></TD> // four columns wide and height to fit text
</TR>
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: <input> with large text blocks

Post by AbraCadaver »

You probably want to use textarea.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
dreeves
Forum Commoner
Posts: 39
Joined: Thu Oct 22, 2009 8:53 am

Re: <input> with large text blocks

Post by dreeves »

That's working a lot better. Thanks!

Now I'm just working with resizing the textarea using styles. Any ideas? I'm new to CSS.

How can I make sure that the formatting (returns & indention) is stored in my database?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: <input> with large text blocks

Post by AbraCadaver »

dreeves wrote:That's working a lot better. Thanks!

Now I'm just working with resizing the textarea using styles. Any ideas? I'm new to CSS.

How can I make sure that the formatting (returns & indention) is stored in my database?
You should probably store it in the database just as it is and then modify it for display:

Code: Select all

echo nl2br(str_replace(' ', '&nbsp;', $text));
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Re: <input> with large text blocks

Post by kaszu »

Now I'm just working with resizing the textarea using styles. Any ideas? I'm new to CSS.
Attributes

Code: Select all

<textarea cols="..." rows="..."
or CSS

Code: Select all

textarea { width: ...px; height: ...px; }
Post Reply