473,383 Members | 1,880 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

simple layer visibility function

hi, i've got 5 thumbnail images.

each one will have a brief decription, in a layer below it, set to visibility:hidden;

when the user mouse overs each image, the info will be displayed.

i got the first one working using 2 functions, one to apear and one to disapear.

how do i keep my script simple, and just use these functions to do the same effect on the other 4 images.

at the moment, when you mouseover image 2, decription for both images is displayed.


here's the javascript

Expand|Select|Wrap|Line Numbers
  1. <script language="javascript1.2">
  2.  
  3. function tAppear()
  4. {
  5.     document.getElementById("t1").style.visibility = "visible";
  6.     document.getElementById("t2").style.visibility = "visible";
  7.  
  8. }
  9.  
  10. function tDisappear()
  11. {
  12.     document.getElementById("t1").style.visibility = "hidden";
  13.     document.getElementById("t2").style.visibility = "hidden";
  14. }
  15.  
  16.  
  17. </script>
  18.  
and the html

Expand|Select|Wrap|Line Numbers
  1. <table width="100%" border="0" cellspacing="5" cellpadding="6">
  2.   <tr>
  3.     <td bgcolor="#f9efda"><span onMouseOver="tAppear()" onMouseOut="tDisappear()"><img src="images/t1.jpg" width="100" height="75" /></span></td>
  4.     <td bgcolor="#f9efda"><span onMouseOver="tAppear()" onMouseOut="tDisappear()"><img src="images/t2.jpg" width="100" height="75" /></span></td>
  5.     <td bgcolor="#f9efda">&nbsp;</td>
  6.     <td bgcolor="#f9efda">&nbsp;</td>
  7.     <td bgcolor="#f9efda">&nbsp;</td>
  8.   </tr>
  9.   <tr>
  10.     <td bgcolor="#f9efda"><div id="t1">Never Forget<br />€10</div></td>
  11.     <td bgcolor="#f9efda"><div id="t2">Viva La Evolución <br />€10</div></td>
  12.     <td bgcolor="#f9efda">&nbsp;</td>
  13.     <td bgcolor="#f9efda">&nbsp;</td>
  14.     <td bgcolor="#f9efda">&nbsp;</td>
  15.   </tr>
  16. </table>
  17.  

thanks
Oct 25 '07 #1
5 1867
acoder
16,027 Expert Mod 8TB
Use an argument in your function, e.g.
Expand|Select|Wrap|Line Numbers
  1. function tAppear(id)
  2. {
  3.     document.getElementById(id).style.visibility = "visible";
  4. }
then you can re-use this function for all layers.
Oct 26 '07 #2
thanks!!!!!!!!!!!!!!!!
Oct 26 '07 #3
acoder
16,027 Expert Mod 8TB
No problem, you're welcome :)
Oct 26 '07 #4
Use an argument in your function, e.g.
Expand|Select|Wrap|Line Numbers
  1. function tAppear(id)
  2. {
  3.     document.getElementById(id).style.visibility = "visible";
  4. }
then you can re-use this function for all layers.
Wouldn't it just be easier just to use DOM? I made some example code that uses it but he seems happy with the onclicks in his code... Oh how I hate onclick :)
Oct 26 '07 #5
acoder
16,027 Expert Mod 8TB
Wouldn't it just be easier just to use DOM? I made some example code that uses it but he seems happy with the onclicks in his code... Oh how I hate onclick :)
I only suggested a simple change using the OP's code. You could, if you want, show your alternative solution.
Oct 29 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Rob Wahmann | last post by:
I'm using the script below to show/hide layers and I'm wondering how to make one layer display be default. Is there a way to make layer 0 display (or any layer) when the page loads? Thanks for any...
4
by: BGT | last post by:
Hi I have some layers, at the same position. I want to show one of them according to the system language, and I have made this so far: function showit() { if (lang == "da")...
2
by: ckerns | last post by:
How can I check to see if a layer is visible? I have four layers and I want to check each to use in an if...then...else statement. tia
3
by: Merlin | last post by:
Hi there, I am trying to create a form with an dynamic field that can be shown or hidden. As I saw for example on google it is possible with JS to show a layer and move the content underneath...
2
by: JS | last post by:
Hi all, Im having some troubles with layers on a site im developing. I have two layers one has an image of an artists palette on it and each blob of paint is a link to a page on the site. That...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.