Tails
01-17-2003, 08:30 PM
Is it possible to convert a string to a variable? Well, here's one example with tables. In the function, X is a number passed on by an href or onClick event. You can't assign an ID as a numer though. So I tried giving each table an ID like t0, t1, t2, etc and
just combine numbers from the event passed on to a t to form the ID and work with one function instead of one per table.
function tab(X)
{
A="t"+X
A.style.backgroundColor="blue"
}
But now A is a string. I can't pass t0 or t1 as an event becaues it's
undefined.
onMouseOver="tab(t0)"
But if I put them in quotes in it
onMouseOver="tab('t0')"
it is also treated like a string and won't be recognized as anything when trying to get that to work as an ID. What can I do to fix this?
just combine numbers from the event passed on to a t to form the ID and work with one function instead of one per table.
function tab(X)
{
A="t"+X
A.style.backgroundColor="blue"
}
But now A is a string. I can't pass t0 or t1 as an event becaues it's
undefined.
onMouseOver="tab(t0)"
But if I put them in quotes in it
onMouseOver="tab('t0')"
it is also treated like a string and won't be recognized as anything when trying to get that to work as an ID. What can I do to fix this?