PDA

View Full Version : How to colspan same elements in table?


aiya
02-27-2004, 10:43 PM
Hi all, I have a simplified HTML which shows the outcome of a javascript. For each <td></td>, it contains the same elements. How can i write in javascript to check for same elements in each <td></td> and colspan the <td> so that in this case, C1238 (tutorial room 65) should appear once and colspan should count to 3 and how to show a separation between C1238 (tutorial room 65)and C2345(tutorial room 54)? Any kind help is greatly appreciated.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table width="75%" border="1" cellspacing="1" cellpadding="1">
<tr>
<td><p>C1238 (tutorial room 65)</p>
<p>C2345(tutorial room 54)</p></td>
<td>C1238(tutorial room 65)</td>
<td>C1238(tutorial room 65)</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</body>
</html>

Willy Duitt
02-27-2004, 10:55 PM
Originally posted by aiya
Hi all, I have a simplified HTML which shows the outcome of a javascript.

Where's the javascript?

.....Willy

aiya
02-28-2004, 01:20 AM
Sorry, what I mean was I have a scenario as shown, how can I use javascript to detect for same elements in the <td> and colspan the elements according?? Any advice?

Willy Duitt
02-28-2004, 09:05 AM
I suppose it is possible by using the DOM and find the children of the tagName('TR') and then use setAttribute('colspan')

But why would you need javascript to do this?
This should be done when the table is written.

.....Willy

Jon Hanlon
02-28-2004, 06:24 PM
It's a bit late trying to add colspan elements after the table has been rendered.