LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices


Reply
  Search this Thread
Old 09-03-2005, 09:19 PM   #1
darin3200
LQ Guru
 
Registered: Dec 2002
Distribution: Gentoo!
Posts: 1,153

Rep: Reputation: 45
Javascript help


I was going to put this programming, but this is scripting so I'll put it here.
I want to several jpegs on a page, and when the user's mouse point goes over an image, that image will change to a different image. However the problem I'm having is when a hover over the second picture, the first image changes to the picture the second one was supposed to change to, and the second one doesn't change. Here is the code i'm using

Code:
<A HREF="http://site-to-link-to.com/pictures1/index.html" 
     onMouseOver="document.images.animate.src='picture1.gif';
                  return true" 
     onMouseOut="document.images.animate.src='picture1.jpg'">
    <IMG SRC="picture1.jpg" WIDTH="90" HEIGHT="90"
         HSPACE="0" VSPACE="0" BORDER="0" ALIGN=LEFT
         NAME="animate">
 </a>
<A HREF="http://site-to-link-to.com/pictures2/index.html" 
     onMouseOver="document.images.animate.src='picture2.gif';
                  return true" 
     onMouseOut="document.images.animate.src='picture.jpg'">
    <IMG SRC="picture2.jpg" WIDTH="90" HEIGHT="90"
         HSPACE="0" VSPACE="0" BORDER="0" ALIGN=LEFT
         NAME="animate"></a>
All help is greatly appreciated
 
Old 09-03-2005, 09:42 PM   #2
spooon
Senior Member
 
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 51
Both images have the same name ("animate")!!! How does it know which one to change?
 
Old 09-03-2005, 11:26 PM   #3
darin3200
LQ Guru
 
Registered: Dec 2002
Distribution: Gentoo!
Posts: 1,153

Original Poster
Rep: Reputation: 45
I've tried to change names but then it doesn't work. What changes do I ned to make?
 
Old 09-03-2005, 11:44 PM   #4
spooon
Senior Member
 
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 51
Instead of "document.images.animate" I think it should be "document.images["animate"]" because images is an array or something.
 
Old 09-03-2005, 11:58 PM   #5
darin3200
LQ Guru
 
Registered: Dec 2002
Distribution: Gentoo!
Posts: 1,153

Original Poster
Rep: Reputation: 45
Ok, you were right that is was a naming problem. I'm not familar with javascript that much and thought that the documents.images.animate part was some for of library routine or something built in not a name. So I changed the names to test and it works great
Thanks!
Code:
<A HREF="http://site-to-link-to.com/pictures2/index.html" 
     onMouseOver="testsrc='picture2.gif';
                  return true" 
     onMouseOut="test.src='picture.jpg'">
    <IMG SRC="picture2.jpg" WIDTH="90" HEIGHT="90"
         HSPACE="0" VSPACE="0" BORDER="0" ALIGN=LEFT
         NAME="test"></a>
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript maseby Programming 1 04-09-2004 05:16 PM
javascript in <td>? akaash Programming 0 03-18-2004 12:22 AM
JavaScript TextAreas jacksmash Programming 9 12-27-2003 01:02 PM
Help with javascript? BajaNick Linux - Software 2 07-20-2003 08:41 PM
javascript?? Marci Sarwan Programming 1 01-18-2001 09:18 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > General

All times are GMT -5. The time now is 09:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration