Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > fill a textarea

Reply
Thread Tools

fill a textarea

 
 
Werner
Guest
Posts: n/a
 
      10-07-2006
Hello,
how can fill automatically a textarea when opening a webpage.
I want to do this by a function that has been raised in js file.

thx
 
Reply With Quote
 
 
 
 
wooolis@gmail.com
Guest
Posts: n/a
 
      10-07-2006
Werner wrote:
> Hello,
> how can fill automatically a textarea when opening a webpage.
> I want to do this by a function that has been raised in js file.


I belive the innerHTML is the way to get stuff into a textarea tag.

--
http://creativeobjectworld.com - (cow)
a free-form, text-based, browser-based, real-time, multi-user virtual
world.

 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      10-07-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Werner wrote:
>
>>Hello,
>>how can fill automatically a textarea when opening a webpage.
>>I want to do this by a function that has been raised in js file.

>
>
> I belive the innerHTML is the way to get stuff into a textarea tag.
>

I prefer setting textarea.value.

--
Ian Collins.
 
Reply With Quote
 
agapeton@gmail.com
Guest
Posts: n/a
 
      10-07-2006
You need to use the 'value' attribute on the textarea (not innerHTML).
Furthermore, you need to access it AFTER the page has loaded, not
before. So, you need to put it in a function that is executed after
the page has loaded. So, the following won't work at all...


<script type="text/javascript">
<!--
document.getElementById('taMyText').value = 'asdfsdf';
// -->
</script>

This is what you want...

<script type="text/javascript">
<!--
window.onload = function(evt) {
document.getElementById('taMyText').value = 'asdfsdf';
}
// -->
</script>

Given this xhtml:
<textarea id="taMyText"></textarea>

Werner wrote:
> Hello,
> how can fill automatically a textarea when opening a webpage.
> I want to do this by a function that has been raised in js file.
>
> thx


 
Reply With Quote
 
David Dorward
Guest
Posts: n/a
 
      10-07-2006
(E-Mail Removed) wrote:

> You need to use the 'value' attribute on the textarea (not innerHTML).


Property, not attribute.

> Furthermore, you need to access it AFTER the page has loaded, not
> before.


You don't need to wait for the entire page to load, just for the textarea to
be created.

> This is what you want...
>
> <script type="text/javascript">
> <!--


You don't want HTML comments in your script elements. They only serve to
protect browsers of the Pre-Netscape 3 generations (and they have much
bigger problems then rendering JS as text) and are actively harmful in
XHTML.

> Given this xhtml:
> <textarea id="taMyText"></textarea>


The rows and cols attributes are not optional.

>> how can fill automatically a textarea when opening a webpage.
>> I want to do this by a function that has been raised in js file.


Why are you responding and /then/ quoting what you are responding to? Its
backwards and makes no sense.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to fill out textarea in html form Terry Todd Ruby 0 09-20-2008 05:37 PM
How to add </textarea> within <textarea> tags? frank.moens@gmail.com Javascript 1 07-04-2007 04:00 PM
Textarea Inside of a textarea wperry1@gmail.com ASP General 6 02-05-2006 08:00 AM
Removing carriage returns from <textarea></textarea> input Augustus ASP General 1 09-10-2003 04:55 AM
Expanding a textarea to fill a window, but without requiring scrollbars David Javascript 3 07-05-2003 04:50 AM



Advertisments