E
Erik Lautier
Hi, I'm having trouble making a DIV show up; here's the background:
I'm building a message board system where if the message is more than
100 characters, the link "more" appears after the first 100 characters.
When the user clicks it, the full message replaces the truncated one.
I'm pulling a DIV switch and loading the first (the truncated message)
as display:block and the second (the full message) as display:none.
OnClick, the switch is pulled. This *should* be working but I can't
understand the glitch; when I click on the link, the truncated message
disappears, but it's not being replaced by anything. Could it be
because I'm generating the DIVs dynamically? I'm naming them based on
a message ID from a DataReader, but for testing purposes, I've var'd
the relevant IDs in the code. Any help would be appreciated; I've
copied the Javascript and relevant HTML below. Thanks!
<script language="JavaScript">
var ids=new Array('ids23','ids24');
function switchid(id){
hideallids();
showdiv(id);
}
function hideallids(){
//loop through the array and hide each element by id
for (var i=0;i<ids.length;i++){
hidediv(ids);
}
}
function hidediv(id) {
//safe function to hide an element with a specified id
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById(id).style.display = 'none';
}
else {
if (document.layers) { // Netscape 4
document.id.display = 'none';
}
else { // IE 4
document.all.id.style.display = 'none';
}
}
}
function showdiv(id) {
//safe function to show an element with a specified id
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById(id).style.display = 'block';
}
else {
if (document.layers) { // Netscape 4
document.id.display = 'block';
}
else { // IE 4
document.all.id.style.display = 'block';
}
}
}
</script>
<tr><td><p class='level1'><img src='images/point.gif' align='left'
border='0'><div id='ids23' style="display:block;">What if I write a
very long reply to this message? Will it return where it should or go
back to the <a
href="javascript:switchid('ids24');">...more</a></div><div id='ids24'
style="display:none;">What if I write a very long reply to this
message? Will it return where it should or go back to the beginning of
the line? Stay tuned for the exciting conclusion!</div></td>
I'm building a message board system where if the message is more than
100 characters, the link "more" appears after the first 100 characters.
When the user clicks it, the full message replaces the truncated one.
I'm pulling a DIV switch and loading the first (the truncated message)
as display:block and the second (the full message) as display:none.
OnClick, the switch is pulled. This *should* be working but I can't
understand the glitch; when I click on the link, the truncated message
disappears, but it's not being replaced by anything. Could it be
because I'm generating the DIVs dynamically? I'm naming them based on
a message ID from a DataReader, but for testing purposes, I've var'd
the relevant IDs in the code. Any help would be appreciated; I've
copied the Javascript and relevant HTML below. Thanks!
<script language="JavaScript">
var ids=new Array('ids23','ids24');
function switchid(id){
hideallids();
showdiv(id);
}
function hideallids(){
//loop through the array and hide each element by id
for (var i=0;i<ids.length;i++){
hidediv(ids);
}
}
function hidediv(id) {
//safe function to hide an element with a specified id
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById(id).style.display = 'none';
}
else {
if (document.layers) { // Netscape 4
document.id.display = 'none';
}
else { // IE 4
document.all.id.style.display = 'none';
}
}
}
function showdiv(id) {
//safe function to show an element with a specified id
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById(id).style.display = 'block';
}
else {
if (document.layers) { // Netscape 4
document.id.display = 'block';
}
else { // IE 4
document.all.id.style.display = 'block';
}
}
}
</script>
<tr><td><p class='level1'><img src='images/point.gif' align='left'
border='0'><div id='ids23' style="display:block;">What if I write a
very long reply to this message? Will it return where it should or go
back to the <a
href="javascript:switchid('ids24');">...more</a></div><div id='ids24'
style="display:none;">What if I write a very long reply to this
message? Will it return where it should or go back to the beginning of
the line? Stay tuned for the exciting conclusion!</div></td>