473,327 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

textarea loosing children

the following code doesn't fill the textarea when i click on button,
it's only show a blank textarea with Firefox browser, while it works
using IE browser.
Changing the method's value to 'visibility' it works using both browsers.

<html>
<head>
<script type="text/javascript">
function showObj(obj,show,method){
if (method=="visibility")
obj.style.visibility = show ? "visible" : "hidden";
else
obj.style.display = show ? "" : "none";
}

function fillTextArea(obj){
showObj(obj.parentNode,true,'display');
obj.appendChild(document.createTextNode("here i am"));
}
</script>
</head>
<body
onload="showObj(document.getElementById('sectionZ' ),false,'display');">
<div id="sectionZ">
<textarea id="fieldn" name="fieldn"></textarea>
</div>
<button onclick="fillTextArea(document.getElementById('fie ldn'));">fill
it</button>
</body>
</html>

How can I fix it using the display property?

Thanx
fusillo
Jun 26 '06 #1
3 1893
fusillo wrote:
the following code doesn't fill the textarea when i click on button,
it's only show a blank textarea with Firefox browser, while it works
using IE browser.
Changing the method's value to 'visibility' it works using both browsers.

<html>
<head>
<script type="text/javascript">
function showObj(obj,show,method){
if (method=="visibility")
obj.style.visibility = show ? "visible" : "hidden";
else
obj.style.display = show ? "" : "none";
}

function fillTextArea(obj){
showObj(obj.parentNode,true,'display');
obj.appendChild(document.createTextNode("here i am"));


I don't know why you get what you get, but if you change this to:

obj.value = "here i am";
Firefox plays the game, other browsers should too.

[...]
--
Rob
Jun 26 '06 #2


fusillo wrote:
the following code doesn't fill the textarea when i click on button,
it's only show a blank textarea with Firefox browser, while it works
using IE browser.


If you want to manipulate the text a textarea renders then use the value
property e.g.
textareaElementObject.value = "here i am"
to set the value or e.g.
textareaElementObject.value += "here i am"
to append.

The contents of a HTML textarea element is defined as #PCDATA so it does
not contain any child elements
<http://www.w3.org/TR/html4/interact/forms.html#edef-TEXTAREA>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 26 '06 #3
thanx for your answers, the code posted is only a test. it runs using
the value property.
Jun 26 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Csaba Gabor | last post by:
What I'd like to do is to be able to set the font of a textarea element to the same font that another element is using (say, for example, an <INPUT type=text ...> element, but if that's a no go,...
1
by: Volt | last post by:
is there any way to select and mark part of text in textarea by regular expression? i need to select the first string in textarea whitch is like xxxxx,xxx where x is any character
4
by: TJS | last post by:
can the rows and columns of a textarea element with an id be changed on the fly ? if so is there an example ?
8
by: ASP Yaboh | last post by:
I have an ArrayList of data gathered from a database. I want to create a web page from this data by creating a <table>, each cell in each row displays the appropriate data. One of those cells in...
6
by: wperry1 | last post by:
I am writing a small database utility to catalog all of my favorite ASM/JS/VBS... functions and scripts on an asp page. Everything is going smoothly except for one thing that I can't quite seem to...
6
by: Tony | last post by:
The w3schools HTML tag reference for <textarea> http://www.w3schools.com/tags/tag_textarea.asp says that the attributes 'cols' and 'rows' are REQUIRED attributes for the textarea tag. Looking at...
4
by: jay_dev | last post by:
i have this slight of problem my page displays a div tag each time a new info is inserted but if i hit the back history button,move back to an earlier page then come back to the one i was working...
23
by: Angus | last post by:
Hello I have a DIV with various elements eg: <div ARID="8" ARType="Char" ARDBN="Short Description"> <label class="label f9" for="arid8"Short Description</label> <textarea class="text sr "...
3
by: FunkHouse9 | last post by:
I'm working on a form to collect data in a textarea which and am trying to keep returns and spaces. I have a couple of functions that I Frankensteined together to replace returns with <br> and to...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.