By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,729 Members | 1,343 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,729 IT Pros & Developers. It's quick & easy.

fill a textarea

P: n/a
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
Oct 7 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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.

Oct 7 '06 #2

P: n/a
wo*****@gmail.com 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.
Oct 7 '06 #3

P: n/a
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
Oct 7 '06 #4

P: n/a
ag******@gmail.com 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
Oct 7 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.