943,177 Members | Top Members by Rank

Ad:
Sep 1st, 2010
0

Javascript unable to create href in div and unable to apply second mouseover function

Expand Post »
Hi there:

The code below lays out 3 divs, the 1st. div contains a slideshow, the 2nd. div is a container for the 3rd div which contains buttons to override the slideshow and replace it with a new image in the slidshow div.

All the above scenario works perfectly.

Where I run into trouble is as follows:
1. When a button is hover, the image needs to change but I already have a onmouseover() function for each button
2. When the image changes, it need to have a href to example: file8.php to open in _self - I have 2 commented lines in my changeIt function to show the last things I tried.

The currently functioning site is:
http://mbtech.products-and-services.ca

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. // div containing the slideshow
  2. <div id="photoSlider" align="center">
  3. // initial image displayed
  4. <a href="javascript:gotoshow()"><img src="../cms/fckeditor/uploadfiles/common/people.png" name="slide" border=0 width=765 height=150/></a>
  5. // javascript to load slideshow
  6. <script>
  7. //configure the paths of the images, plus corresponding target links if you want
  8. slideshowimages"image1.jpg","image2.jpg","image3.jpg","image4.jpg")
  9. slideshowlinks("file1.php","file2.php","file3.php","file4.php")
  10. //configure the speed of the slideshow, in miliseconds
  11. var slideshowspeed=2000
  12. var whichlink=0
  13. var whichimage=1
  14. function slideIt(){
  15. if (!document.images)
  16. return
  17. document.images.slide.src=slideimages[whichimage].src
  18. whichlink=whichimage
  19. if (whichimage<slideimages.length-1)
  20. whichimage++
  21. else
  22. whichimage=0
  23. setTimeout("slideIt()",slideshowspeed)
  24. }
  25. // run the slideshow
  26. slideIt()
  27.  
  28. // javascript to override slideshow from a image button in another div - replaces slideshow image with another image and allows that image to be clicked on to load a new page
  29. function changeIt(imageName,objName,objLink){
  30. var obj = document.getElementById(objName);
  31. var imgTag = "<img src='"+imageName+"' border='0' height='150px' width='765px' />";
  32.  
  33. whichlink=whichimage
  34. obj.innerHTML = imgTag;
  35. // my problem lies after this point. I cannot seem to get teh 2 comments lines to work when uncommented
  36. //var link = "<a href='"objLink"' />";
  37. whichlink = whichimage
  38. obj.innerHTML = imgTag;
  39. //document.write = link;
  40. return;
  41. }
  42. </script>
  43. </div>
  44. <div class="leftColumn_home">
  45. <div class="upper_leftColumn">
  46. <div> //div containing 4 buttons that replace photoSlider images with a new image and
  47. <img border="0" hspace="20" alt="" vspace="2" width="181" height="43" src="button1.jpg" onclick="changeIt('image5.jpg','photoSlider','file5.php')" onmouseover="this.style.opacity=1;this.filters.alpha.opacity=100"
  48. onmouseout="this.style.opacity=0.4;this.filters.alpha.opacity=40" />
  49. </div>
  50. <div>
  51. <img border="0" hspace="20" alt="" vspace="2" width="181" height="43" src="button2.jpg" onclick="changeIt('image6.jpg','photoSlider','file6.php)" onmouseover="this.style.opacity=1;this.filters.alpha.opacity=100"
  52. onmouseout="this.style.opacity=0.4;this.filters.alpha.opacity=40" />
  53. </div>
  54. <div>
  55. <img border="0" hspace="20" alt="" vspace="2" width="181" height="43" src="button3.jpg" onclick="changeIt('image7.jpg','photoSlider','file7.php)" onmouseover="this.style.opacity=1;this.filters.alpha.opacity=100"
  56. onmouseout="this.style.opacity=0.4;this.filters.alpha.opacity=40" />
  57. </div>
  58. <div>
  59. <img border="0" hspace="20" alt="" vspace="2" width="181" height="43" src="button4.jpg" onclick="changeIt('image8.jpg','photoSlider','file8.php)" onmouseover="this.style.opacity=1;this.filters.alpha.opacity=100"
  60. onmouseout="this.style.opacity=0.4;this.filters.alpha.opacity=40" />
  61. </div>
  62. </div>
  63. </div>

I will greatly appreciate help with this as I have hashed trough all obj related javasctipt functions and searched tirelessly on the internet for this solution.

Best Regards,
dennishall
Last edited by Ezzaral; Sep 1st, 2010 at 2:40 pm. Reason: Added code tags. Please use them to format any code that you post.
Similar Threads
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
dennishall is offline Offline
70 posts
since Nov 2009
Sep 1st, 2010
0
Re: Javascript unable to create href in div and unable to apply second mouseover function
UPDATE: I removed teh onmouseover() and onmouseout() functions in the buttons and get it from my css (my bad on that basic oversight).

My issue is only as follows:

When the image changes, it need to have a href to example: file8.php to open in _self - I have 2 commented lines in my changeIt function to show the last things I tried.
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
dennishall is offline Offline
70 posts
since Nov 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: How to make CSS opacity setting work in IE7 ?
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: div overflow:auto not working in div innerhtml





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC