What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Javascript variable help[solved]

Javascript variable help[solved]
Author: Message:
QtanJ
Junior Member
**


Posts: 37
34 / Male / –
Joined: Nov 2005
O.P. Javascript variable help[solved]
I have a IPB forum v.2 and want a spoiler tag. Since I don't want to modify my IPB forum yet, I want to use custom bbcode. I've got this code, but don't have a clue of how I make a variable decide what id number every spoiler need.

code:
<script language="JavaScript" type="text/JavaScript">
<!--
function toggleVisibility(obj)
{
      var Value=Math.random()*57568745757456
     document
if (obj!=null)
{
if (document.getElementById)
{
var current = (document.getElementById(obj).style.display == 'block') ? 'none' : 'block';
document.getElementById(obj).style.display = current;
}
else if (document.all)
{
var current = (document.all[obj].style.display == 'block') ? 'none' : 'block'
document.all[obj].style.display = current;
}
}
}
//-->
</script>
<p>
<a href="javascript:toggleVisibility('Value')">Spoiler</a>
</p>

<div id='Value' style="display:none;">
<p style="background-color:FF0000;FONT-SIZE: 24pt;">
{content}
</p>
</div>

{content} is right, i've testen and that part works.

If I make it {option} then I can make something like this to get it work with more than one each page
code:
Spoiler for somethingunique:
What I want in spoiler

What's wrong with this solution is:
1. You have to write something unique after = in every spoler tag
2. If you quote you need to change the id of the spoiler if you don't want the second spoiler to be a remote control of the first one.


The random number don't have to be a random number multiplied with that numeber i chose there, but it needs to have many choices since i don't like remote controls.

To test if your solution works, just make a html file with two or more spoilers and check if the second one works and that it isn't a remote control.

As the code is now it should work once in each page since the id of every spoiler is value.


Thanks for every answer.

This post was edited on 02-19-2006 at 10:29 PM by QtanJ.
Linux > Windows
Opengl > DirectX
02-19-2006 08:12 PM
Profile E-Mail PM Find Quote Report
ShawnZ
Veteran Member
*****

Avatar

Posts: 3146
Reputation: 43
32 / Male / Flag
Joined: Jan 2003
RE: Javascript variable help.
Almost impossible to do without modifying IPB. you'd at least need to convert them to DIVs with IDs before you can do anything useful with them.
Spoiler:
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
02-19-2006 08:16 PM
Profile PM Web Find Quote Report
QtanJ
Junior Member
**


Posts: 37
34 / Male / –
Joined: Nov 2005
O.P. RE: Javascript variable help.
I've managed to make it. The sourcecode looks like a mess, but at least it works. Feel free to use it as you like as long as you want.
code:
<script language="JavaScript" type="text/JavaScript">
<!--
function toggleVisibility(obj)
{
     
     document
if (obj!=null)
{
if (document.getElementById)
{
var current = (document.getElementById(obj).style.display == 'block') ? 'none' : 'block';
document.getElementById(obj).style.display = current;
}
else if (document.all)
{
var current = (document.all[obj].style.display == 'block') ? 'none' : 'block'
document.all[obj].style.display = current;
}
}
}
var Value = Math.random()*57568745757456;
document.write("<a href=");
document.write('"javascript:toggleVisibility(');
document.write("'");
document.write(Value);
document.write("')");
document.write('">Spoiler</a>');

document.write("<div id=");
document.write("'");
document.write(Value);
document.write("'");
//-->
</script>
style="display:none;">
<p style="background-color:FF0000;FONT-SIZE: 24pt;">
{content}
</p>
</div>

Sorry, I didn't express myself how I needed help clear enough, but case solved.
Linux > Windows
Opengl > DirectX
02-19-2006 10:28 PM
Profile E-Mail PM Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
35 / Male / Flag
Joined: Mar 2004
RE: Javascript variable help[solved]
wtf is with the document.write ewwww  , have you heard of using document.createElement and then appendChild it into the document.
[Image: dt2.0v2.png]      Happy Birthday, WDZ
02-20-2006 03:31 AM
Profile PM Web Find Quote Report
QtanJ
Junior Member
**


Posts: 37
34 / Male / –
Joined: Nov 2005
O.P. RE: Javascript variable help[solved]
Actually no. Javascript isn't the computer language I know best. When it's about websites I usually program in PHP, but in this case I couldn't use it.

It works, and then I have no need to use functions I didn't find in the guides I searched for when I tried to solve this problem.

I don't think I can ever use the easy solutions that needs 20 minutes every time  you loose the modified file or uprgrade, instead of making a code that takses seconds to install when you first have the code.


Thanks for trying to help both of you.
Linux > Windows
Opengl > DirectX
02-20-2006 01:58 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On