473,396 Members | 1,898 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,396 software developers and data experts.

Clearing output text from the HTML body

2
Hello,

I wish to clear text that has been outputted by javascript to an HTML element such as the body. The text is outputted using the appendChild() method. I want to be able to clear any text that has been added that way.

I've provided some sample code of what I want to do below:
Expand|Select|Wrap|Line Numbers
  1.   <head>
  2.     <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
  3.     <title></title>
  4.     <script type="text/javascript">
  5.  
  6. function outputLine()
  7. {
  8.   var li = document.createElement('LI');
  9.   li.appendChild(document.createTextNode("Hello!"));
  10.   document.getElementById('updateTarget').appendChild(li);
  11. }
  12.  
  13. function clearBody()
  14. {
  15.     //??? document.getElementById('updateTarget').???
  16. }
  17.    </script>
  18.   </head>
  19.   <body id='updateTarget' onLoad='outputLine()'>
  20.     <form name=select onsubmit='clearBody()'>
  21.         <input type=submit value="Clear Me">
  22.       </form>
  23.   </body>
Dec 14 '07 #1
3 1531
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

Unless you keep tabs on what has been added, I don't think there's an easy way of doing this. Every time, you use appendChild to add something, store the object in an array and then remove these using removeChild in your clearBody() function.
Dec 14 '07 #2
botank
2
Thank you, although it's not the way I hoped to do it, it works.
Dec 17 '07 #3
acoder
16,027 Expert Mod 8TB
Thank you, although it's not the way I hoped to do it, it works.
Yes, not clean, but I can't think of anything else at the moment.
Dec 18 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Lisa | last post by:
I need to apply the HTML formatting tags and the French accented characters in a XML document. The XML is generated from a database that has HTML tags and French accented characters in the records....
6
by: Wescotte | last post by:
I'm writing a tiny php app that will log into our bank of america account and retrieve a file containing a list of checks that cleared the previous day. The problem I'm running into is when I...
3
by: Joseph A Romeo | last post by:
I have written an XSLT transformation on an ASP.NET page. The resulting HTML is primarily a table of links. I have found that when the resulting HTML is less than or equal to 16040 bytes, the...
4
by: astromac | last post by:
I'm new to php and was wondering if the following was possible... I would like to have a list of items loaded from a text file, process each item in the list and then return the processed result...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.