Solved

Swapping Images using javascript

Posted on 2011-03-08
2
526 Views
Last Modified: 2013-12-14
I want to create an image similar to this : http://www.returnloads.net/loads.asp?area=12

Loading the images dynamically from a database, i.e. 1 main image and then depending on the area the mouse rolls over in the map overlay one of four images would be loaded to replace the original one. again when the mouse rolls off the image the original image is returned.  I've tried using the attached codebehind  BUT it's not working because of the syntax problems associated with the javascript and the ' quotes.

        Image7.Attributes.Add("usemap", "#map1")
        Dim Mainimg As String = "main.jpg"
        Dim img1 As String = "graphics/a.gif"
        Dim img2 As String = "graphics/b.jpg"
        Dim img3 As String = "graphics/c.gif"
        Dim img4 As String = "graphics/d.gif"

        Litadvert.Text &= "<map name='Map1' id='Map1'>"
        Litadvert.Text &= "<area shape='rect' coords='2,1,123,108' href='' onmouseover='javascript:ctl00_CPHReturnLoadsAdvert_Image7.src='" & img1 & "'' onmouseout='javascript:ctl00_CPHReturnLoadsAdvert_Image7.src='" & mainimg &"'"/>"
        Litadvert.Text &= "<area shape='rect' coords='134,1,259,108' href='' onmouseover=javascript:ctl00_CPHReturnLoadsAdvert_Image7.src='" & img2 & "' onmouseout='MM_swapImgRestore()'/>"
        Litadvert.Text &= "<area shape='rect' coords='269,1,394,108' href='' onmouseover='javascript:ctl00_CPHReturnLoadsAdvert_Image7.src='" & img3 & "'' onmouseout='javascript:ctl00_CPHReturnLoadsAdvert_Image7.src='" & mainimg &"'"/>"
        Litadvert.Text &= "<area shape='rect' coords='405,1,525,108' href='' onmouseover='javascript:ctl00_CPHReturnLoadsAdvert_Image7.src='" & img4 & "'' onmouseout='javascript:ctl00_CPHReturnLoadsAdvert_Image7.src='" & mainimg &"'"/>"
        Litadvert.Text &= "</map>"

Where mainimg and img1 etc would in reality be loaded from a database,

This is giving syntax errors and the mouseover evnt isn't working.

Can anyone suggest a way of fixing this or an alternative to do the same thing?
0
Comment
Question by:markej
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 35069763
It looks like it is just a syntactic issue because of the quotes. Try it as:
 Litadvert.Text &= "<area shape=""rect"" coords=""2,1,123,108"" href="""" onmouseover=""javascript:ctl00_CPHReturnLoadsAdvert_Image7.src='" & img1 & "'"" onmouseout=""javascript:ctl00_CPHReturnLoadsAdvert_Image7.src='" & mainimg & "'"" />"

Open in new window

You might need to stick a few spaces in there to check for yourself which are quotes and which are apostrophes :)
0
 

Author Closing Comment

by:markej
ID: 35070243
Great it works, thanks for the help
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question