469,353 Members | 2,093 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,353 developers. It's quick & easy.

Dynamic Table Creation, colspan issue.

Hello,
I've done some searching around the post, and I have found quite a bit of information related to the setAttribute and it's related uses. My problem lies in the usage of colspanning in dynamic table creation.

Code Snippet
Expand|Select|Wrap|Line Numbers
  1. <SCRIPT LANGUAGE="JavaScript">
  2.   function morecase(id){
  3.     var tbody = document.getElementById(id).getElementsByTagName("TBODY")[0];
  4.     var row1=document.createElement('TR');
  5.     var row1td1=document.createElement('TD');
  6.     row1td1.appendChild(document.createTextNode('Incident: '));
  7.     var row1td2=document.createElement('TD');
  8.     row1td2.appendChild(document.createElement('INPUT'));
  9.     row1td2.setAttribute('TYPE','text','NAME','incident');
  10.     var row2=document.createElement('TR');
  11.     var row2td1=document.createElement('TD');
  12.     row2td1.appendChild(document.createTextNode('Blah blah blah blah blah blah blah'));
  13.     row2td1.setAttribute('colspan','2');
  14.     row1.appendChild(row1td1);
  15.     row1.appendChild(row1td2);
  16.     row2.appendChild(row2td1);
  17.     tbody.appendChild(row1);
  18.     tbody.appendChild(row2);
  19.   }
  20. </script>
  21.  
Everything works, but the COLSPAN does not process.
I can pass other commands to the TD (width, bgcolor, etc.) and they work fine, COLSPAN is just my headache.

Any help would be greatly appreciated!

William

POST NUMBER 1 Woo! :rolleyes:
May 14 '06 #1
8 22828
NM, I fixed it :-)
May 14 '06 #2
How did you fix it?

Hello,
I've done some searching around the post, and I have found quite a bit of information related to the setAttribute and it's related uses. My problem lies in the usage of colspanning in dynamic table creation.

Code Snippet
<SCRIPT LANGUAGE="JavaScript">
function morecase(id){
var tbody = document.getElementById(id).getElementsByTagName(" TBODY")[0];
var row1=document.createElement('TR');
var row1td1=document.createElement('TD');
row1td1.appendChild(document.createTextNode('Incid ent: '));
var row1td2=document.createElement('TD');
row1td2.appendChild(document.createElement('INPUT' ));
row1td2.setAttribute('TYPE','text','NAME','inciden t');
var row2=document.createElement('TR');
var row2td1=document.createElement('TD');
row2td1.appendChild(document.createTextNode('Blah blah blah blah blah blah blah'));
row2td1.setAttribute('colspan','2');
row1.appendChild(row1td1);
row1.appendChild(row1td2);
row2.appendChild(row2td1);
tbody.appendChild(row1);
tbody.appendChild(row2);
}
</script>

Everything works, but the COLSPAN does not process.
I can pass other commands to the TD (width, bgcolor, etc.) and they work fine, COLSPAN is just my headache.

Any help would be greatly appreciated!

William

POST NUMBER 1 Woo! :rolleyes:
Sep 17 '06 #3
papppp
1
Not very polite to say you fixed it and not to explain HOW, don't you think?

Anyway, colspan is actually spelled colSpan! It is a "casing" problem.
Oct 9 '06 #4
kiuziu
1
Expand|Select|Wrap|Line Numbers
  1. tr1 = document.createElement('tr');
  2. tbody1.appendChild(tr1);
  3. td1 = document.createElemen("td");
  4. tr1.appendChild(td1);
  5. td1.setAttribute("colSpan",2);
  6.  

//ok
Dec 11 '06 #5
Another solution:

var td = document.createElement('td');
td.colSpan = 5; // for example
Jan 22 '07 #6
itb564
1
It is really working, but it is not becoming a static table row.
How should i make it as a static one?
Feb 29 '08 #7
acoder
16,027 Expert Mod 8TB
By static, do you mean fixed width? Post your code.
Feb 29 '08 #8
Another solution:

var td = document.createElement('td');
td.colSpan = 5; // for example

colSpan .. eso ers muchas gracias !!!!
Oct 25 '08 #9

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Tom | last post: by
2 posts views Thread by The_Original_MB | last post: by
2 posts views Thread by Dave Williamson | last post: by
1 post views Thread by nsvmani | last post: by
reply views Thread by Eniac | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.