Javascript

show hide div

Page 1 of 1

4 Replies - 1256 Views - Last Post: 04 July 2003 - 12:53 PM

#1 .sva  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 33
  • Joined: 26-May 03

Javascript

Posted 03 July 2003 - 12:14 PM

me again.

i've got a blog that im working on, and basicly what i want is a javascript that when you click on a link, the comments for the day's post will become visible under the post. so just some thing to show and hide (with the same link) div really.

i've looked all around the web but can;t really find anything usefull.
Is This A Good Question/Topic? 0
  • +

Replies To: Javascript

#2 klewlis  Icon User is offline

  • cur tu me vexas?

Reputation: 8
  • View blog
  • Posts: 1,723
  • Joined: 09-November 01

Re: Javascript

Posted 03 July 2003 - 03:58 PM

i believe you need to combine it with css's "visibility" property. do a search for that and you should come up with something good (it's been years since i tried it ;)
Was This Post Helpful? 0
  • +
  • -

#3 fyrestorm  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 10
  • View blog
  • Posts: 3,113
  • Joined: 04-April 02

Re: Javascript

Posted 03 July 2003 - 06:02 PM

i've done that before, but the javascript takes advantage of the <ul> and <li> tags...i'll see if i can find my code for that
Was This Post Helpful? 0
  • +
  • -

#4 Koenie  Icon User is offline

  • What?!

Reputation: 0
  • View blog
  • Posts: 1,313
  • Joined: 08-July 02

Re: Javascript

Posted 04 July 2003 - 02:57 AM

You can try to use the css "display" property. Set it to "block" to view it and set it to "none" to make it invisible.
Was This Post Helpful? 0
  • +
  • -

#5 .sva  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 33
  • Joined: 26-May 03

Re: Javascript

Posted 04 July 2003 - 12:53 PM

i found this, it was actually in the new version of invision board, and it does exactly what i want

<script language="Javascript" type="text/javascript">
function ShowHide(id1, id2) {
   if (id1 != '') expMenu(id1);
   if (id2 != '') expMenu(id2);
	}
	
	function expMenu(id) {
   var itm = null;
   if (document.getElementById) {
  itm = document.getElementById(id);
   } else if (document.all){
  itm = document.all[id];
   } else if (document.layers){
  itm = document.layers[id];
   }
	
   if (!itm) {
    // do nothing
   }
   else if (itm.style) {
  if (itm.style.display == "none") { itm.style.display = ""; }
  else { itm.style.display = "none"; }
   }
   else { itm.visibility = "show"; }
	}
    //-->
    </script>


and the link to activate it (incase someone else wants this scipt)

<a href="javascript:ShowHide('DIVid_open','commentsDIVid_closed');">


justa quick note, you need a div named DIVID_open (replace DIVID with the name you want, obviously), but you don't need the _closed version, well i don't have it though.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1