Toggeling Layers..

..with javascript in NS6

Page 1 of 1

4 Replies - 6700 Views - Last Post: 17 July 2002 - 11:01 AM

#1 sva  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 14-June 02

Toggeling Layers..

Posted 16 July 2002 - 05:30 PM

basicly, i ned a smiple script that will toggle a layer (div), i know i can toggle it with the document.getElementById, but i only want one link, so when you click the link the layer becomes visible, then click the same link to hide the layer

any help would be apreciated,

--sva--
Is This A Good Question/Topic? 0
  • +

Replies To: Toggeling Layers..

#2 supernova333  Icon User is offline

  • D.I.C Addict

Reputation: 4
  • View blog
  • Posts: 590
  • Joined: 12-March 02

Re: Toggeling Layers..

Posted 16 July 2002 - 07:28 PM

Dreamweaver has built-in functions for hiding/showing layers as well as dragging them around the browser. They may not be the best there is but they work. Attached is an htm file of a basic example of the show-hide layer behavior using text links:

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#3 supernova333  Icon User is offline

  • D.I.C Addict

Reputation: 4
  • View blog
  • Posts: 590
  • Joined: 12-March 02

Re: Toggeling Layers..

Posted 16 July 2002 - 07:30 PM

I just realized that you specified that you want the same link to toggle the hide/show. The example I have above is 2 seperate links. sorry :(
Was This Post Helpful? 0
  • +
  • -

#4 LeprechauN  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 2
  • View blog
  • Posts: 857
  • Joined: 12-March 01

Re: Toggeling Layers..

Posted 16 July 2002 - 09:47 PM

I'm not very good with javascript but I know a bit, here's somthing I just tried to do for ya, it works :)

<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<script language="Javascript">

function toggle () {
	if (id_name1.style.display == "none") {
		id_name1.style.display = '';
		id_name2.style.display = 'none';
	}
	else {
		id_name1.style.display = 'none';
		id_name2.style.display = '';
	}
}

</script>
</head>
<a href="[url=http://www.dreamincode.net/forums/forum/32-java/]Java[/url] script:toggle()">Toggle!</a><br><br>

<table style="display: ''" id="id_name1">
<tr>
	<td>Toggling, wheeeeeeeeeeeeeeee!</td>
</tr>
</table>

<table style="display: 'none'" id="id_name2">
<tr>
	<td>Toggling, wheeee!</td>
</tr>
</table>

<body>

</body>
</html>

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#5 sva  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 14-June 02

Re: Toggeling Layers..

Posted 17 July 2002 - 11:01 AM

cheers :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1