Forum Moderators: open

Message Too Old, No Replies

Pre-filled text area on form.

this is an easy one

         

mmmwowmmm

5:37 am on Feb 24, 2006 (gmt 0)

10+ Year Member



Hello,

I was wondering if anyone could help me out with this: Below is part of a form - what I want is for the text box to be "pre-filled" with some text. What do I need to add to acheive this?

I know this is a very newbie question, if anyone could help, I'd really appreciate it - thanks.

<form method='post'>
<input type='hidden' name='action' value='postnewpage' />
<table>
<tr><td valign='top'>$[NewPage]:</td>
<td><textarea name='description' cols='40' rows='8'></textarea>
</td></tr></table>
<div align='center'><input type='submit' value='$[submit new page]' />
</div>
</form>

***********************************************
If you need to see the complete form, here it is:

<form method='post'>
<input type='hidden' name='action' value='postnewpage' />
<table>
<tr><td class='newpagefield'> $[Author]:</td>
<td><input type='text' name='author' value='\$Author' /></td></tr>
<tr><td class='seitenname'>$[Group]:</td>
<td><input type='text' name='group'value='Enter Site Name Here'></td></tr>";
/* <td><select name='group' >" ;
foreach($NewGroup as $k=>$v) {
$x = is_string($k)? $k : $v;
$out[] = "<option value='$x'>$v</option>";
} */
$out [] = "
<tr><td class='gruppe'>$[Pagename]:</td>
<td><input type='text' name='newpagename'></td></tr>";

$out[] = "
<tr><td valign='top'>$[NewPage]:</td>
<td><textarea name='description' cols='40' rows='8' ></textarea>
</td></tr></table>
<div align='center'><input type='submit' value='$[submit new page]' />
</div>
</form>

mmmwowmmm

6:36 am on Feb 24, 2006 (gmt 0)

10+ Year Member



This is weird - it seems like I should be able to just change the line:
<td><textarea name='description' cols='60' rows='15'>
to:
<td><textarea name='description' value='MY TEXT HERE' cols='60' rows='15'>

But that is not working. Is that supposed to work? This is part of a larger php script, so it might be a problem with the script itself. Just thought I'd mention that, in case it helps...

Phil

DrDoc

6:56 am on Feb 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<textarea name='description' cols='40' rows='8'>text goes here</textarea>

percentages

7:05 am on Feb 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



DrDoc, has it right.

HTML is not a very consistent form of scripting, and textarea is a good example of how confusing it can get.

I've been coding in raw HTML for 7+ years, and it often catches me out once in a while as well (especially with table formats and backgrounds).

My advice is to keep several examples of the confusing stuff so that you can refer to it again & again when it simply hasn't gelled yet!

mmmwowmmm

7:15 am on Feb 24, 2006 (gmt 0)

10+ Year Member



Hey, thanks a lot, that worked fine. It does seem like an odd place to put it, very counter-intuitive. I really never would have thought of that by just guessing.

DrDoc

7:50 am on Feb 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Actually, I don't think that's counter intuitive at all. For all tags which have both an opening and closing tag, the content simply resides between them. This is true for several other form elements:

<label></label>
<button></button>
<fieldset></fieldset>
<textarea></textarea>

It is only elements requiring no closing tag which have an attribute defining the content:

<img src>
<input value>
<meta content>

:)

What is counter intuitive, however, is that the content can still be accessed in JavaScript using

value
. But that is simply a mechanism for keeping consistency with the other input elements I would imagine.