?
Solved

referring to an image

Posted on 2005-04-09
17
Medium Priority
?
230 Views
Last Modified: 2006-11-18
why is this code not working, i am getting an error that the code doesnt recognize document

onmouseover="showHint(document['pic1'].src='http://www.englishtrunkshowco.com/images/mom0312q.jpg');"


meanwhile this works (shows text)

onmouseover="showHint('something 1');"

0
Comment
Question by:finnstone
  • 7
  • 7
  • 3
17 Comments
 
LVL 32

Expert Comment

by:Batalf
ID: 13743674
Could you show your showHint() function?

This line

onmouseover="showHint(document['pic1'].src='http://www.englishtrunkshowco.com/images/mom0312q.jpg');"

doesn't make much sense to me. I guess it could be rewritten to

onmouseover="showHint('Something 1');document.getElementById('pic1').src='http://www.englishtrunkshowco.com/images/mom0312q.jpg');"

where 'pic1' is the id of the image(e.g.: <img id="pic1" src="whatever.gif" border="0"> )

0
 
LVL 63

Expert Comment

by:Zvonko
ID: 13743685
Either this:

onmouseover="this.src='http://www.englishtrunkshowco.com/images/mom0312q.jpg';"


Or this:

onmouseover="document.images.pic1.src='http://www.englishtrunkshowco.com/images/mom0312q.jpg';"

0
 
LVL 63

Expert Comment

by:Zvonko
ID: 13743693
In my example is pic1 the NAME of the image.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:finnstone
ID: 13743698
function showHint(v) {
    var d = document.getElementById('target');
    d.innerHTML = v;
}
0
 

Author Comment

by:finnstone
ID: 13743702
i need the mouseover effect to load a picture in a different area of the web page (its going to be like a preview box)...the picture needs to be called
0
 
LVL 32

Expert Comment

by:Batalf
ID: 13743703
Then your mouseover should be

showHint('Something')

followed by the image change

My solution:

onmouseover="showHint('Something 1');document.getElementById('pic1').src='http://www.englishtrunkshowco.com/images/mom0312q.jpg';"

where the ID of the image is 'pic1' (<img id="pic1" src="whatever.gif">)

or Zvonkos:

onmouseover="showHint('Something');document.images.pic1.src='http://www.englishtrunkshowco.com/images/mom0312q.jpg'"
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 13743705
Forget the showHint() and use plain IMG tag src attribute assignment.
0
 
LVL 32

Assisted Solution

by:Batalf
Batalf earned 500 total points
ID: 13743713
Yes, off course:-) I thought you wanted to both show some text and change an image

Zvonkos

onmouseover="document.images.pic1.src='http://www.englishtrunkshowco.com/images/mom0312q.jpg';"

should probably do the trick.

Batalf
0
 

Author Comment

by:finnstone
ID: 13743717
zvonko, dont i have to use showhint that will change the image without a page refresh in the preview box when a different value is hovered on? please elaborate if you have a simpler solution...thanks alot!
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 1500 total points
ID: 13743721
And if you want to show an image instead of text in the hint area, then use this:

onmouseover="showHint('<img src=/images/mom0312q.jpg border=0>');"

0
 

Author Comment

by:finnstone
ID: 13743723
sorry i did not explain clearly, i wanted to show a picture on a different part of the page from where the mousrover is occuring , thats why i think i have to use this showhint code. am i correct?
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 13743730
For all the scripting that Batalf and I provide you need no page refresh.

My previous proposal can be rewritten to this:

onmouseover="showHint('<img src=\'/images/mom0312q.jpg\' border=\'0\' >');"



0
 

Author Comment

by:finnstone
ID: 13743734
zvonko thats it! guys, i need more help at this question...

http://www.experts-exchange.com/Web/Web_Languages/CSS/Q_21382589.html


NOTE YOU ANSWERED QUESTION 1 OF 5 in that question
0
 

Author Comment

by:finnstone
ID: 13743740
how is that second piece of code different, the first one was what i was looking for. thanks.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 13743791
The second example adds only \' for attribute values.
That is not necessary, but I prefer putting values in string delimeters.
0
 

Author Comment

by:finnstone
ID: 13743805
i would appreciate your help with the css example, i cannot get it to work in a select box as you can see it at

http://englishtrunkshowco.com/test4.htm

if you try to put those options inside the select box (i do this by removing the input button from inside the select box), the hover sstops working

thanks zvonko
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 13743893
I understand what you want to do, but I have no solution for that.
From my opinion you cannot get any control over Option hover events because the select object is full under control of the system.
The next  aproximation I know about that is the onChange event handler of the select object. Put your hover calls in that event handler.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

807 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