AbidingDude
Programmer
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:
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:
JavaScript:
function handle_checkbox(check_in)
{
var ch;
var in_swap=document.createElement("INPUT");
in_swap.setAttribute("type","text");
in_swap.setAttribute("size","12");
in_swap.setAttribute("maxlength","15");
ch=check_in.parentNode; /*Parent node is the <TD>*/
if(check_in.checked==true){
/*Swap the ID # text node with an input field.*/
ch.replaceChild(in_swap,ch.childNodes[0]);
ch.childNodes[0].focus();
}
else{
putback(ch.childNodes[0]);
console.log(ch.childNodes[0]);
}
}