Please Help with hiding and displaying layers using CSS and Javascript

This is a discussion on "Please Help with hiding and displaying layers using CSS and Javascript" within the JavaScript Forum section. This forum, and the thread "Please Help with hiding and displaying layers using CSS and Javascript are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Apr 6th, 2007, 19:27
New Member
Join Date: Apr 2007
Location: London
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Please Help with hiding and displaying layers using CSS and Javascript

Hi,

I really need some help I hope someone out there can help. Basically I'm designing a web page with the content part of the page made of a table which is scrollable showing thumbnails of fashionitems.
Basically, (I'm trying to make this as clear as I can). Each item is contained within it's own table, which is enclosed within a column in the table. And what I would like to do is cover over part of items picture with a semi tranparent layer containing the item details, when a users mouse passes over the item. All other items on the page should remain in full display. I created the Javascript for this however, it only works for the first item in the table. The other items already have the semi-transparent layer on load of the page. And if I mouse over any of them, then only the first item is affected. I have created a static page to get the layout right at first, but it will eventually be done dynamically. Does that make sense at all? I used the same div repeatedly to create each items table, do they have to be unique and if they are how do I create them dynamically? Also how can I turn this into a dynamically created table, with the javascript working?

Here is the code I have used

The CSS code
Code: Select all
#items{width: 640;}
 
#mainpicture {background-color:#ffffff; position:relative; z-index: 1; height: 160px; width: 160px; top:0; right:0; }
 
#picturedetails {background-color:#ffffff; position:relative; z-index: 2; height:80px; width:160px; top: -120px; filter:alpha(opacity=75);-moz-opacity:.75;opacity:.75;}
The Javascript function

Code: Select all
<script language="JavaScript">
function setAllVisible() {
document.getElementById("picturedetails").style.visibility="hidden";
}
</script>
The HTML used to create one row of the table.

Code: Select all
<table bgcolor="#FFFDFD" cellspacing="3">
<tr>
<td>
<table>
<tr>
<td>
<div id="mainpicture" onMouseOver='document.getElementById("picturedetails").style.visibility = 
"visible";' onMouseOut='document.getElementById("picturedetails").style.visibility = "hidden";'>
<a href=""><img src ="../images/products/dresses/dr10164bluefront.jpg" border=0 height="160" width= 
"120" /></a> 
</div>
<div id="picturedetails" onMouseOver='document.getElementById("picturedetails").style.visibility = 
"visible";' onMouseOut='document.getElementById("picturedetails").style.visibility = "hidden";'>
Hello you please work 
<br />Yes
<br />yes
</div> 
</td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td>
<div id="mainpicture" onMouseOver='document.getElementById("picturedetails").style.visibility = 
"visible";' onMouseOut='document.getElementById("picturedetails").style.visibility = "hidden";'>
<a href=""><img src ="../images/products/dresses/dr10109blackfront.jpg" border=0 height="160" width= 
"120" /></a> 
</div>
<div id="picturedetails" onMouseOver='document.getElementById("picturedetails").style.visibility = 
"visible";' onMouseOut='document.getElementById("picturedetails").style.visibility = "hidden";'>
Hello you please work 
<br />Yes
<br />yes
</div> 
</td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td>
<div id="mainpicture" onMouseOver='document.getElementById("picturedetails").style.visibility = 
"visible";' onMouseOut='document.getElementById("picturedetails").style.visibility = "hidden";'>
<a href=""><img src ="../images/products/dresses/dr10173brownfront.jpg" border=0 height="160" width= 
"120" /></a> 
</div>
<div id="picturedetails" onMouseOver='document.getElementById("picturedetails").style.visibility = 
"visible";' onMouseOut='document.getElementById("picturedetails").style.visibility = "hidden";'>
Hello you please work 
<br />Yes
<br />yes
</div> 
</td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td>
<div id="mainpicture" onMouseOver='document.getElementById("picturedetails").style.visibility = 
"visible";' onMouseOut='document.getElementById("picturedetails").style.visibility = "hidden";'>
<a href=""><img src ="../images/products/dresses/dr10198greyfront.jpg" border=0 height="160" width= 
"120" /></a> 
</div>
<div id="picturedetails" onMouseOver='document.getElementById("picturedetails").style.visibility = 
"visible";' onMouseOut='document.getElementById("picturedetails").style.visibility = "hidden";'>
Hello you please work 
<br />Yes
<br />yes
</div> 
</td>
</tr>
</table>
</td>
</tr>
Please I really hope someone can help because I am so stuck right now
Thank you in advance

Last edited by karinne; Apr 12th, 2007 at 17:40. Reason: Please use [code]...[/code] tags when displaying code!
Reply With Quote

  #2 (permalink)  
Old Apr 12th, 2007, 17:38
Junior Member
Join Date: Feb 2007
Location: USA
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Please Help with hiding and displaying layers using CSS and Javascript

I'm no javascript expert...I do know a little though...I mainly code in JAVA...
its coincidental though, as I am also playing around with <div>'s and their visibility attribute for my web pages.

So here is what I've noticed by briefing over some of your code. You have LOTS of syntax errors:
Here's a snippet of your code to show you what I mean, errors are in bold, and I've added comments in bold as well to explain the error -
Code: Select all
document.getElementById("picturedetails").style.vi  sibility="hidden";
// visibility is one word, no spaces
}
</script>
The HTML used to create one row of the table.

Code: Select all
<table bgcolor="#FFFDFD" cellspacing="3">
<tr>
<td>
<table>
<tr>
<td>
<div id="mainpicture" onMouseOver='document.getElementById("picturedetai  ls").style.visibility = 
"visible";' onMouseOut='document.getElementById("picturedetail  s").style.visibility = "hidden";'>
//again, syntax error, you need to spell picturesdetail as one word, and spell it as you defined it
<a href=""><img src ="../images/products/dresses/dr10164bluefront.jpg" border=0 height="160" width= 
"120" /></a> 
</div>
<div id="picturedetails" onMouseOver='document.getElementById("picturedetai  ls").style.visibility = 
"visible";' onMouseOut='document.getElementById("picturedetail  s").style.visibility = "hidden";'>
//same error again
See where I'm going with this? If the code you posted is the code you are using to run the page, you need to look over the code and check for syntax errors, because there are quite a few...and as with any programming language "syntax errors" are not overlooked. One simple typo can halt the running of an entire application.

Fix the errors and run it again...hope it works!

Last edited by karinne; Apr 12th, 2007 at 17:40. Reason: Please use [code]...[/code] tags when displaying code!
Reply With Quote
  #3 (permalink)  
Old Apr 15th, 2007, 03:04
Reputable Member
Join Date: Dec 2005
Location: U.S.A.
Posts: 147
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to ScottR Send a message via Skype™ to ScottR
Re: Please Help with hiding and displaying layers using CSS and Javascript

Ids have to be unique to each page. Classes do not.


IMO, ditch the layers and run as fast and as far as you can!! I would use css and positioning for the items you want to position.
Reply With Quote
Reply

Tags
css, javascript

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] why isnt my javascript displaying the text skat JavaScript Forum 3 Jan 26th, 2008 20:43
Hiding movie clips? monkeygraphik Flash & Multimedia Forum 3 Sep 20th, 2007 14:37
robots and hiding url's welshstew Search Engine Optimization (SEO) 12 Sep 2nd, 2007 16:52
Javascript menu not displaying correclty AdRock Web Page Design 11 Sep 26th, 2006 13:53
Hidden layers using CSS and JavaScript blis102 Web Page Design 1 Jun 29th, 2006 21:17


All times are GMT. The time now is 10:48.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43