Layers

I want to put a graphic named cr.gif that resides in the folder "images" in a layer that will be always placed in the center and the middle of a particular table.

How does the code look for this?
The graphic path is "/images/cr.gif".

Any help would be appreciated,
Thanks Phil
LVL 1
smphilAsked:
Who is Participating?
 
arunrsConnect With a Mentor Commented:
Is your table a dynamic table or is it a static table.

If it is a static table just identify the center cell and add the

"<td><img  src="images/cr.gif"> </img></td>"

Otherwise if it is a dynamic table get the total number of rows using the loop and the total number of columns and then get the center cell and then add this img tag to the cell.

Call the following function in your body onload event.

function PlaceImage()
{
        var oTable = document.getElementById("table1");
      var rowLength = oTable.rows.length;
      var rowNo = Math.ceil(rowLength / 2);
      var oCol = oTable.rows[rowNo - 1].getElementsByTagName("td");

      var colLength = Math.ceil(oCol.length / 2);
      oCol[colLength - 1].innerHTML = "<img src='images/cr.gif'></img>"
}

This function will identify the center cell of the table and place the image in the cell.
Note: set the id attribute of the table to whatever you specify in the line 1 of the function ("table1" here).


Hope this is useful.

arunrs
0
 
arunrsCommented:
How would you want your image to be displayed
1. as a cell in the table( which is in the center)
2. as a background for the table

Do you want to use a separate layer object?

Can you please ellaborate?

arunrs
0
 
smphilAuthor Commented:
arunrs

As a cell which should be centered
0
 
smphilAuthor Commented:
OH YES AND A SEPate LAYER
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.