468,257 Members | 1,450 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Updating a span inside a table

Hi all,
I have an HTML table within which I have a span. When the user
clicks a button I want to update the contents of this span with form
elements table elements (TR,TD).

The problem is that if I do not wrap the span tag inside a TR
and TD, it is not properly placed in the table and the update does not
work at all. However if I do place the span inside a TR and TD, the TR
and TD which was supposed to go into the span is not becoming properly
aligned because now I have nested TR and TDs.

Anyone have any thougts, here is some sample code....

function repeatQuestion(divHtml, divId) {
var elem = document.getElementById(divId);
elem.innerHTML = divHtml; // divHtml contains TD and TRs

}

<table>

<span id="divId"></span> // this does not work
<tr><td><span id="divId"></span></td></tr> // this works but format
messed up

<input type=button onClick=repeatQuestion(divHtml,divId)>

</table>

Thanks in advance,
Jehan
Jul 20 '05 #1
2 10858
Falc2199 wrote:

<table>
<span id="divId"></span> // this does not work
No, it wouldn't. This is invalid HTML. Also there is no content. There
is nothing for the span to affect.
<tr><td><span id="divId"></span></td></tr> // this works but format
messed up
Again, no content.
What layout did you expect? My mindreading skills are weak.
<input type=button onClick=repeatQuestion(divHtml,divId)>
Again, invalid HTML. You cannot put stuff inside a table element that
is not inside a td as well.
</table>

--
jmm dash list at sohnen-moe dot com
(Remove .TRSPAMTR for email)
Jul 20 '05 #2
Falc2199 wrote:
Hi all,
I have an HTML table within which I have a span. When the user
clicks a button I want to update the contents of this span with form
elements table elements (TR,TD).

The problem is that if I do not wrap the span tag inside a TR
and TD, it is not properly placed in the table and the update does not
work at all. However if I do place the span inside a TR and TD, the TR
and TD which was supposed to go into the span is not becoming properly
aligned because now I have nested TR and TDs.

Anyone have any thougts, here is some sample code....

function repeatQuestion(divHtml, divId) {
var elem = document.getElementById(divId);
elem.innerHTML = divHtml; // divHtml contains TD and TRs

}

<table>

<span id="divId"></span> // this does not work
<tr><td><span id="divId"></span></td></tr> // this works but format
messed up

<input type=button onClick=repeatQuestion(divHtml,divId)>

</table>

Thanks in advance,
Jehan


Could you not wrap the rows of the table that you want to change with
<tbody> </tbody> and change its contents?

= Eric

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Falc2199 | last post: by
1 post views Thread by developer | last post: by
1 post views Thread by cover | last post: by
4 posts views Thread by =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?= | last post: by
3 posts views Thread by Trez | last post: by
5 posts views Thread by Brent | last post: by
18 posts views Thread by navyjax2 | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.