limct
asked on
Why and how to solve .setAttribute property that cannot set "rowspan" for the column of dynamic created table?
Hi, my code is:
var newRow = document.getElementById("t blAddSubFi elds").ins ertRow();
newCell = newRow.insertCell();
newCell.innerHTML = "<font face=Verdana size=-1>" + n + "</font>";
newCell.setAttribute("rows pan", "3");
newCell = newRow.insertCell();
newCell.innerHTML = "<font face=Verdana size=-1>" + sfnSubfieldsComboBox(vsCod esTablesFi eldNames, n, "", "", "") + "</font>";
newCell.setAttribute("rows pan", "3");
newCell.setAttribute("alig n", "center");
It gives no run time error but how to solve it?
var newRow = document.getElementById("t
newCell = newRow.insertCell();
newCell.innerHTML = "<font face=Verdana size=-1>" + n + "</font>";
newCell.setAttribute("rows
newCell = newRow.insertCell();
newCell.innerHTML = "<font face=Verdana size=-1>" + sfnSubfieldsComboBox(vsCod
newCell.setAttribute("rows
newCell.setAttribute("alig
It gives no run time error but how to solve it?
And delete the question http:Q_21185661.html as long as nobody comments into that question.
Afterwards you have to ask Community Support to close the duplicate question.
Afterwards you have to ask Community Support to close the duplicate question.
You are setting the 'rowspan' property to the inserted cell rather than to the inserted row, the last two lines should be:
newRow.setAttribute("rowsp an", "3"); //for the inserted row
newCell.setAttribute("alig n", "center"); //for the inserted cell
newRow.setAttribute("rowsp
newCell.setAttribute("alig
LOL :-)
What is a row spaning row??? Isn't it then simply a row?
What is a row spaning row??? Isn't it then simply a row?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
why don't you create the table via innerHTML
1. put a div somewhere where the table should be f.e.: <div id="tbldiv"></div>
2. create the html-code via javascript f.e.: var temp='<table id="bla"><tr><td rowspan=2>1,3</td><td>2</t d></tr><tr ><td>4</td ></tr></ta ble>';
3. place the innerHTML-code into the div: f.e.: document.getElementById('t bldiv').in nerHTML=te mp;
4. after that you can access the table via dhtml. maybe for IE you will need to call another function with a setTimeout('function2("bla ")',10); because IE renders sometimes too slow, so the table isn't created immediately and you can't access it instantly via getElementById after setting the innerHTML propery of the div
hope that helps (and you r able to understand my english :)
i think this should be a little bit easier.
1. put a div somewhere where the table should be f.e.: <div id="tbldiv"></div>
2. create the html-code via javascript f.e.: var temp='<table id="bla"><tr><td rowspan=2>1,3</td><td>2</t
3. place the innerHTML-code into the div: f.e.: document.getElementById('t
4. after that you can access the table via dhtml. maybe for IE you will need to call another function with a setTimeout('function2("bla
hope that helps (and you r able to understand my english :)
i think this should be a little bit easier.
Oooops... sorry! Happens when your cafeteria runs out of coffee!
:-)
hehe :)
By the way. The best idea was from PeterCN: rowSpan
Here my test:
<script>
function addRow(){
n = 100;
var newRow = document.getElementById("t blAddSubFi elds").ins ertRow(1);
newCell = newRow.insertCell();
newCell.innerHTML = "<font face=Verdana size=-1>" + n + "</font>";
newCell.setAttribute("rowS pan", "3");
newCell = newRow.insertCell();
newCell.innerHTML = "<font face=Verdana size=-1>" + 'sfnSubfieldsComboBox(vsCo desTablesF ieldNames, n, "", "", "")' + "</font>";
newCell.setAttribute("rowS pan", "3");
newCell.setAttribute("alig n", "center");
}
</script>
<table id="tblAddSubFields" border="1">
<tr><td>a</td><td>b</td><t d>c</td><t d>d</td><t d>e</td></ tr>
<tr><td>a</td><td>b</td><t d>c</td><t d>d</td><t d>e</td></ tr>
<tr><td>a</td><td>b</td><t d>c</td><t d>d</td><t d>e</td></ tr>
<tr><td>a</td><td>b</td><t d>c</td><t d>d</td><t d>e</td></ tr>
</table>
<a href="javascript:addRow()" >add</a>
Strange effects come when you add twice to same row those spans, but that's another story.
Here my test:
<script>
function addRow(){
n = 100;
var newRow = document.getElementById("t
newCell = newRow.insertCell();
newCell.innerHTML = "<font face=Verdana size=-1>" + n + "</font>";
newCell.setAttribute("rowS
newCell = newRow.insertCell();
newCell.innerHTML = "<font face=Verdana size=-1>" + 'sfnSubfieldsComboBox(vsCo
newCell.setAttribute("rowS
newCell.setAttribute("alig
}
</script>
<table id="tblAddSubFields" border="1">
<tr><td>a</td><td>b</td><t
<tr><td>a</td><td>b</td><t
<tr><td>a</td><td>b</td><t
<tr><td>a</td><td>b</td><t
</table>
<a href="javascript:addRow()"
Strange effects come when you add twice to same row those spans, but that's another story.
How do you expect to see the rowspan at end of the table?
Appending three rows should also not have any visible effects.