Helpful Information
 
 
Category: JavaScript Development
Need help with td javascript funcion call. . .

Okay, I am trying to get a javascript to run on a <td> tag when a page is created.

ex:
<td id=abc onload="bgColor = retrieveData('color')">

As far as I know, you cannot use onload on the <td> tag, but somehow I need to get the script to run when the page loads.

Unfortunately I cannot call this script on the <body> tag as an onload (like this: document.all.abc.bgColor = retrieveData('color') http://www.devshed.com/Talk/Forums/wink.gif becuase I am creating the page on the fly, and will not know how many <td>'s will be created, or their names.

Any ideas?


[This message has been edited by Kiefer27 (edited November 10, 2000).]

Hello again - I just thought of another possible way around this problem, and that would be to use .css. I could use an Onload function on base to change the color defined in the .css file, in which the class (which had the color change) would be attached to all of the <td>'s that would be created on the fly.

Now, if the above cannot be answered, is there a way to change .css files using javaScript?

Thanks . . .

Hello -
Okay, so I think I solved this problem. Instead of using a function call on each <td>, I used class=. Then in the <head>, I created an embedded style sheet which calls the the retrieveData function:

<SCRIPT LANGUAGE = "JavaScript">
<!--
document.write("<style type='text/css' media='screen'> ");

document.write(".tdcolor {background-color : ");
document.write(retrieveData('color'));
document.write(";} ");

document.write(" </style> ");
-->
</script>

Works great now!

-Jason










privacy (GDPR)