#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    12
    Rep Power
    0
    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') 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).]
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    12
    Rep Power
    0
    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 . . .
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    12
    Rep Power
    0
    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

Similar Threads

  1. how to do superclass call in Javascript?
    By nnh97 in forum JavaScript Development
    Replies: 1
    Last Post: April 1st, 2008, 03:45 AM
  2. call php(with output) from javascript
    By entropia in forum JavaScript Development
    Replies: 2
    Last Post: July 7th, 2003, 07:32 AM
  3. how to pass a javascript var a parameter to the bean method call
    By muthukumaran in forum JavaScript Development
    Replies: 0
    Last Post: June 27th, 2003, 03:52 AM
  4. using a css to call a javascript
    By jed in forum JavaScript Development
    Replies: 2
    Last Post: June 23rd, 2002, 10:16 PM
  5. call asp function from javascript
    By alshawver in forum JavaScript Development
    Replies: 6
    Last Post: November 30th, 2001, 02:37 PM

IMN logo majestic logo threadwatch logo seochat tools logo