I am attempting to create an AJAX application which gathers form data, ships it off to the server, extracts the data from the returned XML file and updates the labels of the input fields according to the result (updated successfully, invalid email address, password length must be at least 6 characters, etc).
7 seconds after the label is updated, however, I want it reset to its original state. Thus, I think I need to un-append (remove) the appended child, but my attempts at doing so have failed.
Code: Select all
if ( document.getElementById(id) != null ) /* id is the id of the label of the input field that was validated */
{
/* this basically _appends_ an input field's label. For instance, the label for the password field could have "e;updated successfully"e; appended. */
document.getElementById(id).appendChild( document.createTextNode( ' - ' + response.childNodesїi].firstChild.data ) );
}
[code="Javascript:Reset the Label to it's original state"]function clear()
{
tags = document.formsї'account'].getElementsByTagName('label');
for ( var i = 0; i < tags.length; i++ )
{
/* This is where I am TOTALLY lost */
document.getElementById( tagsїi].getAttribute('id') ).parentNode.removeChild( document.getElementById( tagsїi].getAttribute('id') ).childNodesї0] );
}
}
[quote="Error message returned by Firefox's JavaScript Console"]Error: uncaught exception: [Exception... "Node was not found" code: "8" nsresult: "0x80530008 (NS_ERROR_DOM_NOT_FOUND_ERR)" location: *censored* Line: 78][/quote]
Line 78 is the line after /* This is where I am TOTALLY lost */.
What do I need to do to remove the appended data from the label?