473,398 Members | 2,368 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,398 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 23345
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.