473,396 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Small (?) script change needed.

Hi,

For a hobby site, I found this script and I'd like it to work the other way
around. The content has to show and the visitor has to click to hide it.
Could someone help me please? I'm a total Java-newbie...

TIA
Jaap

Here's the code:

in <head>tag
<script type="text/javascript">
<!--
var storedDiv = null;
function getDiv(oID) {
if(document.getElementById) {
return document.getElementById(oID);
} else if( document.all ) {
return document.all[oID];
} else { return null; }
}
window.onload = function () {
for( var i = 0, y; y = getDiv('ans'+i); i++ ) {
y.style.display = 'none';
}
};
function toggleInfo(oID) {
var oDiv = getDiv(oID); if( !oDiv ) { return; }
oDiv.style.display = (oDiv.style.display=='none') ? 'block' : 'none';
if( storedDiv && storedDiv != oDiv ) { storedDiv.style.display = 'none';
} storedDiv = oDiv;
}
//--></script>
in <body>tag
<span style="cursor:hand; cursor:pointer" onclick="toggleInfo('ans0');">
Hide/show content

</span><br><br>
<div id="ans0">

content

</div>

Jul 23 '05 #1
1 1184
solution: using a different script...

<script type="text/javascript">
/* This goes in the head section */
window.onload = function() {
document.getElementById('hideable').style.display = 'block'; }

function toggle(link, divid) {
var div = document.getElementById(divid);
if (div.style.display == 'none') {
div.style.display = 'block';
link.innerHTML = 'Hide Sponsors';
} else {
div.style.display = 'none';
link.innerHTML = 'Show Sponsors';
}
}
</script>

<a href="#hideable" onclick="toggle(this, 'hideable'); return false;">Hide Sponsors</a><br><br>
<div id="hideable">

content

</div>

"Jaap" <ja********@veldhorst.nl> schreef in bericht
news:PC******************@amsnews05.chello.com...
Hi,

For a hobby site, I found this script and I'd like it to work the other way around. The content has to show and the visitor has to click to hide it.
Could someone help me please? I'm a total Java-newbie...

TIA
Jaap

Here's the code:

in <head>tag
<script type="text/javascript">
<!--
var storedDiv = null;
function getDiv(oID) {
if(document.getElementById) {
return document.getElementById(oID);
} else if( document.all ) {
return document.all[oID];
} else { return null; }
}
window.onload = function () {
for( var i = 0, y; y = getDiv('ans'+i); i++ ) {
y.style.display = 'none';
}
};
function toggleInfo(oID) {
var oDiv = getDiv(oID); if( !oDiv ) { return; }
oDiv.style.display = (oDiv.style.display=='none') ? 'block' : 'none';
if( storedDiv && storedDiv != oDiv ) { storedDiv.style.display = 'none';
} storedDiv = oDiv;
}
//--></script>
in <body>tag
<span style="cursor:hand; cursor:pointer" onclick="toggleInfo('ans0');"> >> Hide/show content

</span><br><br>
<div id="ans0">

content

</div>

Jul 23 '05 #2

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

Similar topics

5
by: Tim Morrison | last post by:
Is there any easy way to create a change script as illustrated below for all tables within a database? Right now I would have to create a seperate script for each table. I would like to be able...
0
by: ZMan | last post by:
Scenario: This is about debugging server side scripts that make calls to middle-tier business DLLs. The server side scripts are legacy ASP 3.0 pages, and the DLLs are managed DLLs...
7
by: Tim Rogers | last post by:
Hi folks, this is a resolution-detect script that I used on a site. As you can see it is designed to detect when the screen resolution falls below a certain level then load an alternative style...
8
by: RomanRusso | last post by:
Hie everybody, Here at this forum I have found something what I was looking for - rotation of cells in html table, here is the link http://www.thescripts.com/forum/threadnav149304-2-10.html The...
9
by: smartbei | last post by:
Hello, I am a newbie with python, though I am having a lot of fun using it. Here is one of the excersizes I am trying to complete: the program is supposed to find the coin combination so that with...
3
by: Angus | last post by:
I have a web page with a toolbar containing a Save button. The Save button can change contextually to be a Search button in some cases. Hence the button name searchsavechanges. The snippet of...
2
by: Jorgen Bodde | last post by:
Hi all, This is slightly OT but it drives me nuts. Whenever I create a shortcut in the start menu (in Windows) of a python script, it will only execute it when the path where the script resides...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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...

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.