Jump to content

Recommended Posts

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>

 

 

Link to comment
https://forums.phpfreaks.com/topic/216487-simple-image-swap/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.