Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

replaceChild() and Keeping Relationships

replaceChild() and Keeping Relationships

replaceChild() and Keeping Relationships

I'm working on a form. The form is a table with pieces of equipment in one column, and the readings from that equipment in another column (plus a few others).
The equipment ID's are hard-coded into the form. Sometimes one of these pieces of equipment malfunctions or has to go out for repair, so we have to use a substitute piece of equipment.
I'm trying to make the form flexible. When the user clicks on a "Change Equipment" button, it adds check boxes to the bottom of the IDs. When a box is checked, I change the text node of the ID to a text entry box. To do that I've been using replaceChild().
After the swap I need to access some of the parent and sibling nodes that surround it. It's been giving me errors. Apparently, when I replace a node, it does not take on the same parent/sibling elements as the original. When I examine the DOM elements of it, it says NULL for all of them.
I tried assigning to parentNode and nextSibling, etc, but they are apparently read-only. How can I get a replacement node to inherit the parents and siblings of the original?

WIP code:

CODE --> JavaScript

function handle_checkbox(check_in)
	var ch;
	var in_swap=document.createElement("INPUT");

	ch=check_in.parentNode; /*Parent node is the <TD>*/
		/*Swap the ID # text node with an input field.*/

RE: replaceChild() and Keeping Relationships

Nevermind. I'm an idiot. The relationships are kept. I was just accidentally checking the replaced node instead of the new one.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close