timt Posted October 21, 2010 Share Posted October 21, 2010 Hello Freaks, Trying to perform a simple image swap of some photos for a product. I am a js novice. 1. load glogal vars for photos. 2. define function to preload photos. 3. call preload function on load. 4. reference img tag with unique name (ex. name="prd7"). 5. on the swap link, change src (ex. document.pdr7.src=prd7photo2.src). Help please. Tim T. . . . <script type="text/javascript"> var prd7photo1 = new Image(); var prd7photo2 = new Image(); var prd8photo1 = new Image(); var prd8photo2 = new Image(); var prd9photo1 = new Image(); var prd9photo2 = new Image(); function loadPhotos() { prd7photo1.src='admin/upload/store7Photo1Sm.jpg'; prd7photo2.src='admin/upload/store7Photo2Sm.jpg'; prd8photo1.src='admin/upload/store8Photo1Sm.jpg'; prd8photo2.src='admin/upload/store8Photo2Sm.jpg'; prd9photo1.src='admin/upload/store9Photo1Sm.jpg'; prd9photo2.src='admin/upload/store9Photo2Sm.jpg'; } </script> </head> <body onload="javascript:loadPhotos()"> . . . <a href="admin/view_photo.php?p=7Photo1" target="_blank"><img src="admin/upload/store7Photo1Sm.jpg" alt="Lucky - Denim Shirt" name="prd7" width="200" id="prd7" /></a><br /> <div class="views"> <a href="javascript:void(0)" class="sub-menu" onclick="javascript:void('document.prd7.src=prd7photo1.src')">Front</a> • <a href="javascript:void(0)" class="sub-menu" onclick="javascript:void('document.prd7.src=prd7photo2.src')">Detail</a> </div> Quote Link to comment https://forums.phpfreaks.com/topic/216487-simple-image-swap/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.