473,785 Members | 2,794 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Spoiler code doesnt work

Thew
69 New Member
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. <script language="javascript" type="text/javascript">
  4.  
  5. function spoilershow(){
  6.  
  7.     document.getElementById("spoiler").style.visibility='visible';
  8.     document.getElementById("show").value='close';
  9.     document.getElementById("show").onclick='spoilerhide()';
  10. }
  11.  
  12. function spoilerhide(){
  13.  
  14.     document.getElementById("spoiler").style.visibility='none';
  15.     document.getElementById("show").value='open';
  16.     document.getElementById("show").onclick='spoilershow()';
  17. }
  18.  
  19. </script>
  20.  
  21. <div onclick="spoilershow()" style="width:300px; border:1px solid black;" id="show" value="open">
  22. <div style="width:300px; visibility:none;">
  23. spoiler
  24. </div>
  25. </div>
  26.  
  27.  
This spoiler doesnt work. Can someone help me fixing it?
Aug 18 '10 #1
2 2211
gumape
2 New Member
Hi,
required modifications:
- The visibility style property does not support the value of 'none', use 'hidden' instead.
- The value of the onclick property cannot be a string, it must refer to a function ('spoilerhide() ' --> spoilerhide)
- The id of the spoiler div is missing.

Repaired code:

Expand|Select|Wrap|Line Numbers
  1. <head>
  2.     <script type="text/javascript"> 
  3.         function spoilershow() {   
  4.             document.getElementById("spoiler").style.visibility='visible'; 
  5.             document.getElementById("show").value='close'; 
  6.             document.getElementById("show").onclick = spoilerhide; 
  7.         } 
  8.  
  9.         function spoilerhide() { 
  10.             document.getElementById("spoiler").style.visibility='hidden'; 
  11.             document.getElementById("show").value='open'; 
  12.             document.getElementById("show").onclick = spoilershow; 
  13.         }   
  14.     </script> 
  15. </head>
  16. <body>
  17.     <div onclick="spoilershow()" style="width:300px; border:1px solid black;" id="show" value="open"> 
  18.         <div style="width:300px; visibility:hidden;" id="spoiler"> 
  19.             spoiler 
  20.         </div> 
  21.     </div> 
  22. </body>
A simpler solution:

Expand|Select|Wrap|Line Numbers
  1. <head>
  2.     <script type="text/javascript"> 
  3.         function ToggleSpoiler () {
  4.             var spoiler = document.getElementById("spoiler");
  5.             if (spoiler.style.visibility == "hidden") {
  6.                 spoiler.style.visibility = "visible";
  7.             }
  8.             else {
  9.                 spoiler.style.visibility = "hidden";
  10.             }
  11.         }
  12.     </script> 
  13. </head>
  14. <body>
  15.     <div onclick="ToggleSpoiler ()" style="width:300px; border:1px solid black;"> 
  16.         <div style="width:300px; visibility:hidden;" id="spoiler"> 
  17.             spoiler 
  18.         </div> 
  19.     </div> 
  20. </body>
I think, the following links will be useful to you:
visibility style property,
display style property,
onclick event,
getElementById method.
Aug 18 '10 #2
Thew
69 New Member
Thank you!!!
Aug 18 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1683
by: sachin bond | last post by:
The following code(in c++) is supposed to divide a file into 'n' different files. suppose i'm having a file called "input.zip". The execution of the following code should divide "input.zip" into 'n'(user specified) different files. However the code currently..though makes 'n' different files... the divided contents are stored only in the first of the 'n' files.
3
2098
by: sachin bond | last post by:
this code does not work.... plz help...... void breaker() {
1
1449
by: chris | last post by:
hi i am trying to make a vb.net control using Imports System.Web Dim email As New System.Web.Mail.MailMessage but it gives me the error Type 'System.Web.Mail.MailMessage' is not defined. why is that however i am able to send messages using asp.net's createobject ("...")
2
2098
by: Rhys.Mataira | last post by:
My code will not show up anything at all on the screen can someone guide me why this would be? <?php $pagetitle="Login"; If (!$_POST) or (!$_POST) { echo" <head></head> <style type=\”text/css\”> <!--
4
2215
by: raaman rai | last post by:
Hi guys, i installed WAMP Server 2 yesterday but i waz surprised to see that the following code doesnt work. Today is <? print strftime("%m/%d/%Y"); ?> The output is just: Today is If i use the proper php tag i.e <?php ?> it works but what i feel is that php5 files do not have the <?php ?> style. So, whats the problem???
1
1599
by: Dany13 | last post by:
hi all. i using some text box for input value and some localvarible for passing this data to dataset . give instance for correct row of dataset and data in data table . use one gird view for showing curent data in dataset . in end i am calling update metod to insert data in sql database but this metod doesnt work correctly. at all doesnt work. but givenot any error . fill data from my database (work propebly) ...
9
1701
by: AGP | last post by:
I've been scratching my head for weeks to understand why some code doesnt work for me. here is what i have: dim sVal as string = "13.2401516" dim x as double x = sVal debug.writeline ( x)
0
1400
by: xteaun | last post by:
Hi! I am trying to use the following code in a little VB.Net project and I just cant get it to work. I get an error that says the "adressof"-command isnt using the right delegate type and some functions seem to be missin return commands?!? Could someone please have a look at this and maybe change it, so it works in VB.Net? Thank you :) Christian ==== Attribute VB_Name = "Module_PaceMaker"
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10152
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...
1
10092
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
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
7500
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
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4053
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
3650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2880
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.