wakrah
12-22-2009, 01:05 PM
Hi i need some help with editing show/hide code it is works fine with me but it is show the content every time i refresh the page what i want is to be the conetent hidden till i click on the link to show the content so every time i refersh the page no thing appear untill i click on the show link.
<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>
<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>