473,657 Members | 2,566 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

onClick makes text appear

Hi,

I try to create the following:

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?
HOW?

Love to hear from you.

Frank H.

Jul 20 '05 #1
4 31649
"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="docume nt.getElementBy Id('text1').sty le.visibility=' visible';">
<div id="text1" style="visibili ty:hidden;">
This text is revealed by button 1 and hidden by button 3.
<input type="button" value="Button 3"
onclick="docume nt.getElementBy Id('text1').sty le.visibility = 'hidden';">
</div>
<input type="button" value="Button 2"
onclick="docume nt.getElementBy Id('text2').sty le.visibility=' visible';">
<div id="text2" style="visibili ty:hidden;">
This text is revealed by button 2 and hidden by button 4.
<input type="button" value="Button 3"
onclick="docume nt.getElementBy Id('text2').sty le.visibility = '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/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
Frank Hoek wrote on 21 nov 2003 in comp.lang.javas cript:
Hi,

I try to create the following:

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?
HOW?


<script>
function sw(y,x){
t=document.getE lementById(x).s tyle
t.visibility=(y =='on')?'visibl e':'hidden'
}
</script>

<style>
#div1,#div2 {visibility:hid den;}
</style>
<button onclick=sw('on' ,'div1')>Show</button>
<div id=div1>
Text of div1
<button onclick=sw('off ','div1')>Hide</button>
</div>

<button onclick=sw('on' ,'div2')>Show</button>
<div id=div2>
Text of div2
<button onclick=sw('off ','div2')>Hide</button>
</div>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #3
Frank Hoek hu kiteb:
Hi,

I try to create the following:

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?
HOW?


This is almost exactly how the menu system in my web pages functions.
Click my sig to find out how - I'm a hit-whore :-)
--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk

Jul 20 '05 #4
Problem solved.
Thanks, guys!

F.
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
10052
by: killerkatt | last post by:
I am new to CSS and would like to know if there is a way to make this happen with CSS: image1 and image 2 are laid out at the top of the page. when the mouse hovers over image1, a paragragh or so of formatted text appears below, when the mouse leaves the image, the text disappears; when the mouse hovers over image2, a different body of text appears in
1
1397
by: Ike | last post by:
I have an onclick() event handler wherein I want to change a value that then needs to be shown in a textbox on a form on the page......can anyone show me how this is done? Thanks, Ike
2
1255
by: tarmstrong | last post by:
Hi. I would like to create a link next to a caption, and when user clicks it, a new text appears and becomes . And when users clicks , it becomes and the text dissapears. I don't remember which JavaScript property I must work with. Thank you very much.
1
4801
by: noleander | last post by:
Hi. I've got a C++ program written in Visual C++ 2003. The program is trivial, created with the Program-creation wizard: used the .NET "Form" template. The program has a trivial single-pane form GUI. I've got some stdout print statements in the code ... but I cannot find where in the world the output text is appearing. For printing I tried both: printf ("Hello world\n"); and Console::Write ("Hello World\n");
3
12774
by: TM | last post by:
I have a messagebox and I would like to display a message along with the some selected text I am searching for. But I would like the selected text to appear as bold. I would like my message box to show: No more items found for: (this text in bold) Is there any way to do that ? Thanks
7
4046
by: shanmukhi | last post by:
Hi All i posted this query already... but i didnt get any solution for my problem.. please anybody can provide solution for this i written a code in my jsp page like this <a id=<%=customer%> href='javascript:subwindow(this.id)'> <%=customer%> </a> my java script function in head section is
2
1157
by: thumper5 | last post by:
I am working on a program that needs to out put a certain line of text from a text file to the .text property of a textbox. any ideas? do you want more specifics on my project?
3
1982
by: computerkid101 | last post by:
Hey everyone, I am making an online quiz (school project) and basically I have 4 radio buttons (the options; multiple choice) and then an answer button. What I want is for the user to answer and submit it and then have javascript check the answer. I then want it to display an appropriate "correct" or "incorrect" below. This is what I have so far: <html xmlns='http://www.w3.org/1999/xhtml'> <head> <meta http-equiv='Content-Type'...
1
3135
by: wewannaknow | last post by:
I want a script that "types" my text letter by letter and also deletes the text letter by letter. I want it to look as if someone is typing the text live, and then when it deletes (letter by letter), it would start from the beginning, erasing the letters in the same pace new letters are being "typed". So this way you would never see the whole text, but only a bit of it at a time. By the time you would get to the end of the text, the...
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8825
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1953
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1611
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.