473,404 Members | 2,174 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,404 software developers and data experts.

Fully destroy an object

Hello Everyone,

I have two functions:
Expand|Select|Wrap|Line Numbers
  1. function purgeNode(node){
  2.     while(node.childNodes.length > 0){
  3.         var childNode = node.firstChild;
  4.  
  5.         if(childNode.childNodes.length > 0)
  6.             purgeNode(childNode);
  7.  
  8.         node.removeChild(childNode);
  9.         childNode = null;
  10.         delete childNode;
  11.     }
  12.  
  13.     node.parentNode.removeChild(node);
  14.     node = null;
  15.     delete node;
  16. }
  17.  
  18. function purgeContent(){
  19.     var content = getObj("content");
  20.     purgeNode(content);
  21. }
I have a text field which is in the content div:
Expand|Select|Wrap|Line Numbers
  1. <input type="text" id="txtCustomer" />
I enter some text(bla) into txtCustomer and do an Ajax request. The response calls purgeContent() and fills the content with some other stuff and a textfield txtCustomer. I type another word in the textfield(test). When I now look at the value of txtCustomer through document.getElementById("txtCustomer").value it says that the value is still the old one(bla) :S. It appears that the first textfield is somehow not entirely destroyed. How do I fully destroy it?

Kind Regards,
Vincent
Jan 2 '08 #1
2 6502
mrhoo
428 256MB
function purgeContent(){
var content = document.getElementById("content");
while(content.lastChild)content.removeChild(conten t.lastChild);
}

This method removes all the childNodes of content.

In IE, an input element has no child nodes, so it isn't getting removed by your node method. If you add another input with the same id the first one defined is returned by document.getElementById.

Your use of delete doesn't do anything- delete is used to remove a property of an object, or an element of an array. If it is called on something that is not an object, an error is supposed to be called, but IE sometimes throws in the window- delete window.node returns true, even if there is no window.node defined.
Jan 3 '08 #2
I see. So is there any way to achieve my goal? I really don't want to write a lot of extra PHP code just because of some old object hanging around.
Jan 4 '08 #3

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

Similar topics

1
by: Thomas Ilsche | last post by:
Hi, how do I "explicitly destroy" an Object in PHP5 to make sure the destructor is called an the object destroyed? unset is not an option because there are multiple variables containing the...
4
by: Peter Oliphant | last post by:
I'd like to be able to destroy a Timer in it's own event handler. That is, within it's tick handler I'd like to delete the Timer itself (e.g., for one-shot timers). Is this possible? In general,...
8
by: vvenk | last post by:
Hello: I just wrote my first ASP.Net application. It worked fine on my machine and when I put into production, the ASP.Net process reaches 50% quite fast and then the system does not work...
2
by: Marco | last post by:
Hello, I have to use the propertyReader of DSOFile.dll for reading/writing custom document properties in a closed document. In the msdn http://support.microsoft.com/?scid=kb;en-us;Q224351...
16
by: LP | last post by:
Hello, I am trying to use .NET with Excel. I installed Office 2003 and selected ..NET programming suport option, so it installed all those PIA, as MS sugests. But I can not find a way to destroy...
6
by: muppetjones | last post by:
I'm pretty new at this, and I'm trying to figure out how Perl's classes work with signals. Specifically, it doesn't seem that a class's DESTROY function is called when you Ctrl-C the program. I...
4
by: Curious | last post by:
Hi, I have a timer object that's launched as below: mTimer = new System.Threading.Timer (new TimerCallBack(SubscribeTrade), null, 15000, 15000); void SubscribeTrade (object state) {...
4
by: Juergen-Bernhard Adler | last post by:
Hello, pretend some noob has (in a fake-static class) provided the following method public static kill_object($obj) { if (!is_object($obj)) return false;
3
by: drzoo2 | last post by:
Completely noob question as I am not a programmer but really trying hard to learn Python (Object oriented programming in general). I am writing a program in python that calls a popup window with...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.