...

View Full Version : simple getDocumentbyID question



canadianjameson
12-10-2004, 07:06 PM
I have a table in which i need certain cells to have a certain background image. I figured the the best way to do this would be as follows:

unfortunantly this code is syntactically incorrect. what is the right syntax?


document.getElementById("backgroundCells").background = 'images/t28_17.gif';


also, i need to apply this to multiple cells on one page, so it cant be document.getElementById is has to be document.getElementByClass.

can i even do this?

Basscyst
12-10-2004, 07:26 PM
If they all have the same bg image then just give them a class and assign the bg image with css. If there are multiple images make multiple classes, or give each a unique ID if they are all different bgs. Unless you want to change the bg on the fly I don't really see the need for the JS.

Basscyst

canadianjameson
12-10-2004, 08:56 PM
good thinking

so i do this:



.cellBG
{ baground-image: images/t28_17.gif }


?

canadianjameson
12-10-2004, 09:02 PM
got it



<style type="text/css">
.cellBG
{ background-image: url('images/t28_17.gif') }
</style>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum