Hi,
I am using Javascript to add rows to tables, etc. in a function I am
calling. I pass the function the ID of the div, and what I want in the
rows, and it will add rows to a table in the div.
The problem is I need to test for the existence of the table - and if
the variable or object doesn't exist already my code errors -
PLEASE REMEMBER - I don't know the name of the variable or object I am
testing the existance for - it is created dynamically based on the
divID. So when I test for this object or variable the test has to be
for a dynamically created object -
I tried typeof(eval('fr mCntrl_tbl_' + divID) == 'object' //this
fails when the object isn't created yet
Any Ideas Would GREATLY be Appreciated!!
Vmusic
==============c ode below========== =============
//determine if a variable for this div already exists
if(typeof(eval( 'frmCntrl_tbl_' + divID) == 'object')) //if the object
does not exist this ERRORS
{
alert('A table variable with the divID ' + divID + ' already exists');
}
else
{
alert('First call the to create the table');
//create a table to hold the options or features for this control
//var frmCntrl_tbl = document.create Element('table' );
eval('var frmCntrl_tbl_' + divID + ' =
document.create Element(\'table \');');
alert('There is a variable frmCntrl_tbl_' + divID + 'of type: ' +
typeof(eval('va r frmCntrl_tbl_' + divID)));
//var frmCntrl_tbody = document.create Element('tbody' );
eval('var frmCntrl_tbody_ ' + divID + ' =
document.create Element(\'tbody \');');
}