Page 1 of 1

<input> with large text blocks

Posted: Thu Jan 14, 2010 8:48 am
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>

Re: <input> with large text blocks

Posted: Thu Jan 14, 2010 10:06 am
by AbraCadaver
You probably want to use textarea.

Re: <input> with large text blocks

Posted: Thu Jan 14, 2010 10:41 am
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?

Re: <input> with large text blocks

Posted: Thu Jan 14, 2010 10:53 am
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));

Re: <input> with large text blocks

Posted: Mon Jan 18, 2010 11:11 am
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; }