Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
Thread Tools Display Modes
Share |
  #1  
Old 12-10-2006, 05:14 AM
MathStud MathStud is offline
Junior Member
 
Join Date: 12-10-06
Location: Yurp
Posts: 8
iTrader: 0 / 0%
Spoiler tag in HTML - mysterious code!

Hello there, and thanks for letting me join the community.
As you've probably guessed, I've come because I need help! So... please help!

A nice little function you can find on several forums is the 'spoiler' function. I wish to implement this into HTML for other uses, so I went to a random forum, copied the spoiler code from the source and copied it to a HTML file. It was a success, but unfortunately, it only works for one spoiler per page. Here is the code, which I suspect is Java:
Code:
<div style="margin-bottom:2px"> Spoiler: <input type="button" value="Display" style="width:65px;font-size:10px;margin:0px;padding:0px;" onclick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = ''; this.innerText = ''; this.value = 'Hide'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = 'Display'; }"> </div> <div style="margin: 0px; padding: 6px; border: 1px inset;"> <div style="display: none;"> Spoiler!<br /> <br /> Spoiler!<br /> <br /> Spoiler! </div> </div>

And if you wish to try it, I have made an HTML page with two spoilers:
Code:
<html> <head></head> <body> <strong>Why doesn't this work?</strong><br /><br /> <div style="margin-bottom:2px"> Spoiler: <input type="button" value="Display" style="width:65px;font-size:10px;margin:0px;padding:0px;" onclick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = ''; this.innerText = ''; this.value = 'Hide'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = 'Display'; }"> </div> <div style="margin: 0px; padding: 6px; border: 1px inset;"> <div style="display: none;"> Spoiler!<br /> <br /> Spoiler!<br /> <br /> Spoiler! </div> </div> <br /><br /> <div style="margin-bottom:0px"> Spoiler2: <input type="button" value="Display" style="width:65px;font-size:10px;margin:0px;padding:0px;" onclick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = ''; this.innerText = ''; this.value = 'Hide'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = 'Display'; }"> </div> <div style="margin: 0px; padding: 6px; border: 1px inset;"> <div style="display: none;"> Spoiler2!<br /> <br /> Spoiler2!<br /> <br /> Spoiler2! </div> </div> </body> </html>
Both buttons open the first spoiler, and I've tried changing the 'div' reference and I've tried changing the numbers in what appears to be Java arrays, but then the second one doesn't work at all.

Any help would be greatly appreciated! Thanks and see you later!
 
Reply With Quote

Advertisement

Advertisement

  #2  
Old 12-10-2006, 08:14 AM
MathStud MathStud is offline
Junior Member
 
Join Date: 12-10-06
Location: Yurp
Posts: 8
iTrader: 0 / 0%
I just want to add that I don't necessarily want to use this spoiler.
If you have another one that works (javascript/php etc.) I would gladly use that one in stead!
 
Reply With Quote
  #3  
Old 12-12-2006, 04:22 AM
MathStud MathStud is offline
Junior Member
 
Join Date: 12-10-06
Location: Yurp
Posts: 8
iTrader: 0 / 0%
Well, thanks for the help...

But I fixed this on my own! Just pack the spoiler in sufficient <div> tags, and they will work seperately!
 
Reply With Quote
  #4  
Old 12-12-2006, 01:04 PM
Izzmo's Avatar
Izzmo Izzmo is offline
v7n Mentor
 
Join Date: 11-01-03
Location: Kansas
Posts: 1,356
iTrader: 1 / 100%
Dang, you got to your own question before I did Math I usually am always here answering questions when I can.

BUT! Look on the bright side, you figured it out all on your own, that's always a sign of improvement.

++ Rep
 
Reply With Quote
  #5  
Old 12-12-2006, 01:26 PM
Taltos's Avatar
Taltos Taltos is offline
v7n Mentor
 
Join Date: 11-22-06
Location: Phoenix, AZ
Posts: 1,797
iTrader: 0 / 0%
See Izzmo, told you that you were needed!! Didn't even think about giving MathStud rep for solving his own problem. Nice!!
 
Reply With Quote
  #6  
Old 12-12-2006, 06:22 PM
MathStud MathStud is offline
Junior Member
 
Join Date: 12-10-06
Location: Yurp
Posts: 8
iTrader: 0 / 0%
Heey!

Thanks guys!
 
Reply With Quote
  #7  
Old 12-13-2006, 12:31 PM
Izzmo's Avatar
Izzmo Izzmo is offline
v7n Mentor
 
Join Date: 11-01-03
Location: Kansas
Posts: 1,356
iTrader: 1 / 100%
Quote:
Originally Posted by Taltos View Post
See Izzmo, told you that you were needed!! Didn't even think about giving MathStud rep for solving his own problem. Nice!!
lol, well thank you sir!
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Html code to go to another website shahab6 Coding Forum 7 03-09-2009 09:11 PM
how to add an html code in a page? madcaptains Coding Forum 9 03-10-2008 05:49 PM
Display HTML code daniel0012 Coding Forum 6 03-11-2007 11:49 AM
HTML code please. Trapper Coding Forum 9 07-27-2006 05:34 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 04:23 PM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC