Topeka
Junior Member
Posts: 94
Topeka said 0 great things
|
Post by Topeka on Jan 30, 2010 19:17:16 GMT -8
Hey, so im making a table by createElement('table') ('tr') ('td') yada yada
and i created it like to have it like this
1st row 1 column 2nd row 1 column 3rd row 1 column 4th row 2 columns 5th row 2 columns 6th row 2 columns
and at the end ive wanted to set the attribute colspan to the 1st, 2nd, and 3rd, row so it fills the 2 columns. But i do not know why it doesn not work.
cell2.setAttribute("colspan", "2");
cell2 = the only 'td' of row 2 So bascially what am i doing wrong?
i think its "working" (as in setting the attribute) but since i created the table somehow it thinks that there isnt 2 tds to fill. so it looks the same.
I have the code if you wanna see it. I dont have a site that shows it cause i created it though notepad so yeah if you can help that would be great.
|
|
|
Post by Wormopolis on Jan 30, 2010 21:17:30 GMT -8
I would just access directly instead of using setAttribute.
table.rows[0].cells[0].colSpan=2; table.rows[1].cells[0].colSpan=2; table.rows[2].cells[0].colSpan=2;
those 3 rows ONLY have 1 cell in them right?
|
|
Topeka
Junior Member
Posts: 94
Topeka said 0 great things
|
Post by Topeka on Jan 31, 2010 10:53:01 GMT -8
MAN. i wrote this whole this to show you what i was doing and i figured it out -.- Stupid capital letters cell1.setAttribute("colSpan", "2") that works. aint it just great also. doing the tabl1.tblbody1.row1.cell1.colSpan=2; kept comming up with null or not an object. so idk what was wrong w/ that. Now the fun begins with making all of this into an array -.- Thx wormo.
|
|
|
Post by Wormopolis on Jan 31, 2010 11:31:53 GMT -8
you left out the brackets. and you dont need tbody:
tablename.rows[0].cells[0].colSpan=2;
but good you got it working nonetheless!
|
|
Topeka
Junior Member
Posts: 94
Topeka said 0 great things
|
Post by Topeka on Jan 31, 2010 13:10:02 GMT -8
why would i need the brackets? i have the var rows/cells set up as
var row1 = document.createElement('tr'); var cell1 = document.createElement('td');
var row2 = tr var cell2 = td
i havent done the array to them.
|
|