"Frank Hoek" <fr*****@planet.nl> writes:
2 buttons next to each other, on a webpage
button 1 makes (onClick) text 1 appear just beneath the button
button 2 makes (onClick) text 2 appear just beneath the button
in each of the texts at the end there's a third button to make the text
dissappear again
IS THIS POSSIBLE?
Yes.
Your caps lock key is stuck :)
HOW?
---
<input type="button" value="Button 1"
onclick="document.getElementById('text1').style.vi sibility='visible';">
<div id="text1" style="visibility:hidden;">
This text is revealed by button 1 and hidden by button 3.
<input type="button" value="Button 3"
onclick="document.getElementById('text1').style.vi sibility = 'hidden';">
</div>
<input type="button" value="Button 2"
onclick="document.getElementById('text2').style.vi sibility='visible';">
<div id="text2" style="visibility:hidden;">
This text is revealed by button 2 and hidden by button 4.
<input type="button" value="Button 3"
onclick="document.getElementById('text2').style.vi sibility = 'hidden';">
</div>
---
I use the CSS property "visibility" to hide and show the texts.
That means that they still take up room on the page, you just can't see
the contents.
You can use "display" instead, setting it to "none" to hide or "block"
to show the text. The advantage of "visibility" is that it works in
more browsers, e.g. Opera 6 (and Netscape 4, but getElementById doesn't
work there).
/L
--
Lasse Reichstein Nielsen -
lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'