Im trying to check if an array is defined while looping through another array
I've been beating my head on syntax options for awhile now.
here's what I got:
Code:
if(eval('self.dd_'+n.id+'[0][0]'))
alert(msg)
This the code in context with function
Code:
function openform(id){
//change button to 'save'
obj.childNodes[b_pos].firstChild.value='save';
//store values in array
var v=0; vArray=new Array(new Array(),new Array(),new Array());
for (i=0; i < obj.childNodes.length; i++){
n=obj.childNodes[i]
if (n.id){
vArray[0][v]=i;
vArray[1][v]=n.innerHTML;
vArray[2][v]=(n.innerText!=undefined?n.innerText:n.textContent)
v++;
}
}
//write input boxes
for (i=0; i < vArray[0].length; i++){
n=obj.childNodes[vArray[0][i]];
w=n.clientWidth;
//>>>>>>> BEGIN PROBLEM AREA <<<<<<<<<<
if(eval('self.dd_'+n.id+'[0][0]'))
alert(msg)
else
alert("self.dd_"+n.id+"[0][0] is not defined")
//>>>>>>> END PROBLEM AREA <<<<<<<<<<
inputwidth=(w>200?30:(w>50?8:1));
n.innerHTML='<input name="'+n.id+'" size="'+inputwidth+'" value="'+vArray[2][i]+'">';
}
}
|