By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,527 Members | 1,229 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,527 IT Pros & Developers. It's quick & easy.

FAQ-page => showing/hiding text

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
> 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

P: n/a
"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

P: n/a
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.