clone.getElementsByTagName("td"[6]has no properties !!
hello,
I always received a message "clone.getElementsByTagName("td")[6] has no properties message !!! how to I avoid this problem ?
Also, I would like to have 1 more row added in "Clock Information section" AND 1 more row added in "Clock's False Path Information" when the button "insert another clock" is pushed...
Can you please help... ?
Thank you very much in advance
The below is my code:
--------------------------------------
var clone;
function cloneDiv_c(){
var divs=document.getElementById('clkDiv').getElementsByTagName('div');
clone=divs[divs.length-1].cloneNode(true);
}
function cloneDiv_fp(){
var divs=document.getElementById('fpDiv').getElementsByTagName('div');
clone=divs[divs.length-1].cloneNode(true);
}
function removeDiv_c(){
var root=document.getElementById('clkDiv');
var divs=root.getElementsByTagName('div');
root.removeChild(divs[divs.length-1]);
}
function removeDiv_fp(){
var root=document.getElementById('clkDiv');
var divs=root.getElementsByTagName('div');
root.removeChild(divs[divs.length-1]);
}
function addDiv_c(){
var root=document.getElementById('clkDiv');
var divs=root.getElementsByTagName('div');
var nr=root.getElementsByTagName('table').length+1;
clone.getElementsByTagName('td')[6].firstChild.nodeValue=nr;
root.appendChild(clone);
clone=divs[divs.length-1].cloneNode(true);
}
function addDiv_fp(){
var root=document.getElementById('fpDiv');
var divs=root.getElementsByTagName('div');
var nr=root.getElementsByTagName('table').length+1;
clone.getElementsByTagName('td')[3].firstChild.nodeValue=nr;
root.appendChild(clone);
clone=divs[divs.length-1].cloneNode(true);
}
function addDiv_clock(){
addDiv_c();
addDiv_fp();
}
function removeDiv_clock(){
removeDiv_c();
removeDiv_fp();
}
function cloneDiv_all () {
cloneDiv_c ();
cloneDiv_fp ();
}
the function cloneDiv_c, as well cloneDiv_fp, are overwriting the variable clone. so, when you call addDiv_c, the clone doesn't contain six cell (td), it actually contain the three cell from clock's false path information. you need two different variable to retain each clone. also, you know there is six cell on each clock information but getElementsByTagName return an HTMLCollection that is similar to array. that is, the collection contain an index. so, the sixth index mean the cell number seven, which doesn't exist. same happen with third index you refer in addDiv_fp. those are the reason why you are getting such error.
my mom is javascript, dad is javascripter, granpa is javascriptor, and my little sister is javasRidiculous. my nature language is javascript, then come spanish and english -- me
Bookmarks