Wrox Programmer Forums
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 17th, 2004, 02:01 PM
Authorized User
 
Join Date: Mar 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default images and events

<head><script language="javascript"/>

function show(text)
{
    for(var i=1;i<4;i++)
    {
    eval("document.all.undermeny"+[i]+".style.visibility='hidden'");
    }

    if (text==1)
    {
    document.all.undermeny1.style.visibility="visible" ;
    }
    else if (text==2)
    {
    document.all.undermeny2.style.visibility="visible" ;
    }
    else if (text==3)
    {
    document.all.undermeny3.style.visibility="visible" ;
    }
    }
</script>
</head>

<body>
<div id="mspot2">
<table border="0">
<tr>
<td><div id="1" onMouseOver="show(1)"><img src="pic1.gif"></div></td>
<td><div id="2" onMouseOver="show(2)"><img src="pic2.gif"></div></td>
<td><div id="3" onMouseOver="show(3)"><img src="pic3.gif"></div></td></tr></table></div>


<div id="undermeny1">
<table cellspacing="0" cellpadding="0" border="0" width="140" height="10">
    <tr><td><a href="eyes.html" target="right"> >-- EYE -- < </a></div></td></tr></div></table></div>
<div id="undermeny2" >
<table cellspacing="0" cellpadding="0" border="0" width="140" height="10">
    <tr><td><a href="lips.html" target="right">>-- LIPS --< </a></div></td></tr></div></table></div>
<div id="undermeny3">
<table cellspacing="0" cellpadding="0" border="0" width="140" height="10"
    <tr><td><a href="skin.html" target="right">>-- SKIN --< </a></div></td></tr></div></table></div>

for those who under this codeplz tell me how can i make <div undermeny2 AND undermeny3 to appear at the same thime - the code only refers to one undermeny3 at a time

 
Old March 17th, 2004, 02:03 PM
Authorized User
 
Join Date: Mar 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

for those who under this code plz tell me how can i make undermeny2 AND undermeny3 to appear at the same time - the code only refers to one undermeny at a time


 
Old March 17th, 2004, 02:09 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Well, I think that in your for statement instead of [i] you should just put i

However, this may not solve your problem.

<script language="javascript"/>

I assume this is a typo if your getting anywhere at all...

<script language="javascript">//your code</script>

HTH,

----------
---Snib---
----------

<><
 
Old March 18th, 2004, 05:39 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Quote:
quote:
for(var i=1;i<4;i++)
{
  eval("document.all.undermeny"+[i]+".style.visibility='hidden'");
}
The above code is awful. This will create three new instances of the Script Engine. NEVER use 'eval'. Just use:
Code:
for(var i=1;i<4;i++)
{
  document.all["undermeny" + i].style.visibility="hidden";
}
As for your main question your function first hides all the divs then shows one. What exactly did you want it to do?

Please don't be offended by this next comment:)
I recommend reading Wrox's Beginning JavaScript by Paul Wilton. It's taking you about a week to knock up a page that should have taken about an hour because you haven't taken the initial time to learn JavaScript basics and the Browser/Document object model.


--

Joe
 
Old March 19th, 2004, 11:06 AM
Authorized User
 
Join Date: Mar 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

no joe, im not offended by ur comment

its true that i know very little about javascript, thats y i joined this forum - ive just started a course in webdesign and so im a bit slow in understanding ur suggestions and being able to explain my problem!

anyway,

i do know what my code means thats y i want to develop it and make it show TWO undermeny's (ex. undermeny2 undermeny3) at the same time when i click on an image






Similar Threads
Thread Thread Starter Forum Replies Last Post
Load Images from and Save Images to a Database cyndie VB.NET 2 August 17th, 2008 06:42 AM
Events bschleusner C# 2005 2 February 26th, 2007 05:25 AM
Customised events in C# LowFlyer VS.NET 2002/2003 2 July 15th, 2004 01:53 PM
help with Events egiblock JSP Basics 0 October 6th, 2003 11:39 PM
How to write events egolileopablo JSP Basics 1 August 28th, 2003 01:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.