View Full Version : Width attribute not taking effect

05-07-2006, 10:49 PM
I am using javascript to create a table-ish layout, I am using the following function to resize the 'cells' within a 'row'. It is layed out such that there is an 'insert cell' at each end to drop new 'cells' into as well as an 'insert cell' between each 'data cell'. Each 'insert cell' is only 1.25% wide and the function should resize the 'data cells' evenly; it does change the width attribute when viewed with firefox's DOM inspector but doesn't actually render as a different width.

Here is the function:

function resizeCells(row){
var datacells=(row.childNodes.length-1)/2;
var insertcells=datacells+1;
var insertcellstotal=insertcells*1.25;
var datacellstotal=100-insertcellstotal;
var datacellwidth=datacellstotal/datacells;
var cells=row.childNodes;
for(var cell=1 ; cell < cells.length ; cell+=2 ){
cells[cell].setAttribute('width',datacellwidth + '%');


edit:All the 'cells' are declared as float:left

05-08-2006, 03:04 AM

cells[cell].setAttribute('width',datacellwidth + '%');

cells[cell].style.width = datacellwidth + '%';

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum