Showing/hiding text
Posted: Tue Feb 19, 2008 1:53 pm
~pickle | Please use
In the body:
~pickle | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi everyone,
I’m trying to write code that will display no text (except a link) and then make text appear when a link is clicked. So far I’ve only managed to write code that loads a page with text and hides the text when a link is clicked. Does anyone know how to edit the code below to make it work as I wish?
Thanks,
Stu
In the header:Code: Select all
var ie4 = false; if(document.all) { ie4 = true; }
function getObject(id) { if (ie4) { return document.all[id]; } else { return document.getElementById(id); } }
function toggle(link, divId) { var lText = link.innerHTML; var d = getObject(divId);
if (lText == 'Show details') { link.innerHTML = 'Hide details'; d.style.display = 'block'; }
else { link.innerHTML = 'Show details'; d.style.display = 'none'; } }
In the body:
Code: Select all
<a title="show/hide" alt='show/hide' id="exps112_link" href="javascript: void(0);" style="text-decoration: none;" onclick="toggle(this, 'exps132');">Hide details</a>
<div id="exps132" style="padding: 0px;" >
TEXT TO SHOW/HIDE GOES HERE
</div>~pickle | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]