473,225 Members | 1,317 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,225 software developers and data experts.

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 23317
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

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

Similar topics

2
by: Tom | last post by:
I would like to know if an .asp case statement can contain HTML elements. I am building an application that I would like to have dynamic choices. The dynamic part would be built in the a case...
0
by: yurps | last post by:
Hello here is my html, if you click the missing image in the first column on the left, the div is shown, when clicked again the div disappears...but the bottom border disappears as well...Is there...
2
by: The_Original_MB | last post by:
I have a task to create tables dynamically, using the javascript DOM. The current method uses a 1px x 1px IFRAME to loop through some data generation stuff, and then call JS functions in the parent...
2
by: Dave Williamson | last post by:
When a ASPX page is created with dynamic controls based on what the user is doing the programmer must recreate the dynamic controls again on PostBack in the Page_Load so that it's events are wired...
1
by: nsvmani | last post by:
Hi, i am trying to get the FileOpen dialogue window as soon as clicked href link I am using IE6 with ActiveX enabled. Just need to get the File Open dialogue window when i click on the HREF links.It...
0
by: Eniac | last post by:
Hi, I've been working on a custom user control that needs to be modified and the validation is causing me headaches. The control used to generate a table of 4 rows x 7 columns to display all...
0
bmallett
by: bmallett | last post by:
First off, i would like to thank everyone for any and all help with this. That being said, I am having a problem retrieving/posting my dynamic form data. I have a form that has multiple options...
1
by: skyson2ye | last post by:
Hi, guys: I have written a piece of code which utilizes Javascript in PHP to create a three level dynamic list box(Country, States/Province, Market). However, I have encountered a strange problem,...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.