View Full Version : Using a variable as a object name in a statement

02-24-2003, 12:32 AM
I'm trying to change the class of a table cell using JavaScript with the onClick event of another cell.

If I use the cell ID (tab1) in the statment:


it works.

But if I assign the cell ID value to a variable and use that as the object ID in the statement:

var tabname="tab1";

it doesn't. But I get no errors

I need to use a variable because I need to change a number of cells and use the 'for' loop to accomplish this using the numeric value on the end of the object name.

I'm sure the answer is very simple but I'm new to this - can anyone help!!!!

02-24-2003, 01:56 AM
The statement:


Still has the script looking for a cell named "tabname". Some one will need to jump in here but you would do something like the following: