FreePgs.com Forum

FreePgs Related => Support Requests => Topic started by: Evilsprouts on May 08, 2006, 08:35:39 PM

Title: Java script link thingy
Post by: Evilsprouts on May 08, 2006, 08:35:39 PM
Umm I have a page which I have a comments bit that goes at the bottom however the page looks too crowded with the comments bit at the bottom so what I want to do is have a link on the page and when the user click it the comment bit is displayed at the bottom. So basically you click the link it displays you click the link again it goes.

Any ideas please????

Thanks!  :)
Title: Re: Java script link thingy
Post by: dest on May 08, 2006, 11:06:25 PM
Put the comments in a div, resize the div on click. 
Title: Re: Java script link thingy
Post by: Evilsprouts on May 11, 2006, 06:46:59 PM
How would I go about doing that please? I had a go but it didn't work :(
Title: Re: Java script link thingy
Post by: brainiac744 on May 11, 2006, 08:20:51 PM
You can use a nice little snippet of code I just found here:

http://www.webmasterworld.com/forum91/441.htm
Title: Re: Java script link thingy
Post by: Evilsprouts on May 11, 2006, 10:20:11 PM
That's cool thanks but how would I make it so that when you click the link it shows the content then when you click it again it hides the content please?

Hers the code I'm using:

<script language=javascript type='text/javascript'>
function hideDiv() {
if (document.getElementById) {
document.getElementById('comments').style.visibility = 'hidden';
}
else {
if (document.layers) {
document.hideShow.visibility = 'hidden';
}
else {
document.all.hideShow.style.visibility = 'hidden';
}
}
}

function showDiv() {
if (document.getElementById) {
document.getElementById('comments').style.visibility = 'visible';
}
else {
if (document.layers) {
document.hideShow.visibility = 'visible';
}
else {
document.all.hideShow.style.visibility = 'visible';
}
}
}
</script>


Thanks
Title: Re: Java script link thingy
Post by: dest on May 11, 2006, 11:19:11 PM
Perhaps add a variable that gets set to different values (true/false, for example) by the two functions, and call a third function that checks the variable and runs show or hide depending on the value.
Title: Re: Java script link thingy
Post by: Guide on May 12, 2006, 05:00:26 PM
Why don't you regroup the two functions in one, toggleDiv, which would first check whether the div is visible or not, and then either show or hide it ?

Something like :


function toggleDiv() {
if(document.getElementById('comments').style.visibility == 'hidden') {
     document.getElementById('comments').style.visibility = 'visible';
}
else {
     document.getElementById('comments').style.visibility = 'hidden';
}
}
Title: Re: Java script link thingy
Post by: Evilsprouts on May 12, 2006, 05:51:01 PM
Ahh thats great thank you very much.