Click to See Complete Forum and Search --> : Expanding text paragraphs - not sure if this is javascript
schwarzefee
04-12-2003, 01:23 AM
I saw this on a site a few years ago, and now that I actually want to use it I can't find it again. I apologize if someone has discussed this here already; as I don't know what the code might be called, I've had a hard time searching for it.
They had it in the FAQ page: there was a list of questions, and when you clicked on one of the questions, the answer to it (paragraphs of text) would appear underneath it. I'm not sure if this is an adequate description or not; can you help?
AdamGundry
04-12-2003, 01:37 AM
Here's something I did a while ago:
<a href="javascript:tog('para')">Switch Paragraph</a>
<div id="para" style="display: none">
<p>Text content here...
</div>
<script type="text/javascript">
function tog(elem){
el = document.getElementById(elem);
if (el.style.display=="none"){
el.style.display = "block"
} else {
if (el.style.display==""){
el.style.display = "block"
} else{
el.style.display = "none"
}
}
}
</script>
Hope this helps
Adam
schwarzefee
04-12-2003, 01:53 AM
It wants to open "java script:tog('para')" as a webpage. Or am I doing something wrong?
AdamGundry
04-12-2003, 01:57 AM
There shouldn't be a space between the words "java script". But anyway, this version is better:
<a href="#" onclick="tog('para')">
Adam
schwarzefee
04-12-2003, 02:01 AM
That's exactly what I want... thank you SO much; I love you forever!!
Mr Initial Man
12-09-2006, 10:21 AM
How would you do that to switch between two paragraphs? Make one appear and the other disappear?