469,306 Members | 1,556 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

FAQ-page => showing/hiding text

Hi,

I'm making a FAQ-page. To keep it a little synoptic, only the questions are
visible. When you klick on a certain question, the answer appears. You can
find an example at: http://www.aendekerk.be/zoom/uitklappen.htm

Suppose i click on "titel1", "tekst1" appears. When i click on "titel2",
"tekst2" appears. But also tekst1 remains visible. I don't want this. How
can i program this?

Thanks!

Dries
Jul 20 '05 #1
5 1101
Dré wrote on 09 feb 2004 in comp.lang.javascript:
I'm making a FAQ-page. To keep it a little synoptic, only the
questions are visible. When you klick on a certain question, the
answer appears. You can find an example at:
http://www.aendekerk.be/zoom/uitklappen.htm

Suppose i click on "titel1", "tekst1" appears. When i click on
"titel2", "tekst2" appears. But also tekst1 remains visible. I don't
want this. How can i program this?


function openen(x) {
s='none'
document.getElementById('text1').style.display=s
document.getElementById('text2').style.display=s
document.getElementById('text3').style.display=s
document.getElementById('text4').style.display=s
document.getElementById('text5').style.display=s

document.getElementById(x).style.display=''
}
<div onclick="openen('text1')">titel van text1</div>
<div id="text1">...........</div>

niet getest, hoor.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #2
Dré wrote:
Hi,

I'm making a FAQ-page. To keep it a little synoptic, only the questions are
visible. When you klick on a certain question, the answer appears. You can
find an example at: http://www.aendekerk.be/zoom/uitklappen.htm

Suppose i click on "titel1", "tekst1" appears. When i click on "titel2",
"tekst2" appears. But also tekst1 remains visible. I don't want this. How
can i program this?

Thanks!

Dries

Keep the ID of the opened question in a public variable, and on click of
an item first close the opened one.

--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Jul 20 '05 #3
> I'm making a FAQ-page. To keep it a little synoptic, only the questions are
visible. When you klick on a certain question, the answer appears. You can
find an example at: http://www.aendekerk.be/zoom/uitklappen.htm

Suppose i click on "titel1", "tekst1" appears. When i click on "titel2",
"tekst2" appears. But also tekst1 remains visible. I don't want this. How
can i program this?


I've found a solution on
http://www.dynamicdrive.com/dynamicindex1/navigate2.htm
Thanks anyway for replying!!

Dries

--
E-mail: dries <punt> aendekerk <ad> advalvas <punt> be

Jul 20 '05 #4
"Bas Cost Budde" <ba*@heuveltop.org> wrote in message
news:c0***********@news2.solcon.nl...
<snip>
Keep the ID of the opened question in a public variable,
and on click of an item first close the opened one.


Rather than saving the ID of the element that needs to be re-hidden as a
string in a global variable it would be more efficient to save a
reference to the element, or, better yet, its style object. It would
save having to re-locate the element within the DOM (getElementById is
not necessarily that fast). The script must have had that reference when
it made the element visible so it can just assign the reference at that
point, having defaulted the global variable to null. Then if the
variable refers to an object when it is time to make a different element
visible it is a simple matter to first render the stored element hidden.

Richard.
Jul 20 '05 #5
Richard Cornford wrote:
"Bas Cost Budde" <ba*@heuveltop.org> wrote in message
Keep the ID of the opened question in a public variable,
and on click of an item first close the opened one.
Rather than saving the ID of the element that needs to be re-hidden as a
string in a global variable it would be more efficient to save a
reference to the element, or, better yet, its style object.


Thanks. Showing my javascript age here :-)
--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by David Fisher | last post: by
reply views Thread by Marshall Cline | last post: by
21 posts views Thread by Boris Ammerlaan | last post: by
6 posts views Thread by Juan T. Llibre | last post: by
19 posts views Thread by Dr John Stockton | last post: by
56 posts views Thread by jacob navia | last post: by
28 posts views Thread by =?ISO-8859-15?Q?Juli=E1n?= Albo | last post: by
20 posts views Thread by FAQEditor | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.