Current location: Hot Scripts Forums » General Web Coding » JavaScript » Dynamic image swap questions


Dynamic image swap questions

Reply
  #1 (permalink)  
Old 02-16-10, 10:26 AM
Smitty Smitty is offline
Newbie Coder
 
Join Date: Mar 2009
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Dynamic image swap questions

Hello,

I am in a touch of a pickle. I've done image swaps with javascript, but am still a javascript newb.

I need to write a product page with a main image and alt images. We want the user to be able to click on the alt image and it will change the main image to the selected image.

Some background:
We have the site located at an ecommerce company that only gives template access. They have it driven by smarty. So I can use their modified smarty, javascript and html. I don't have deeper access
I was brought in after everything had been set up years ago to make the site better and easier to maintain. So I am fixing half decent code in the middle, ugh
Anyway, it's just a tad limited but functions decently for now.


So here is what I have:

This is displaying the images:
Code:
{assign var="cols" value=#sec_img_num_cols#}
{if $product.images|@count > 1}
<br />
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  {counter start=0 assign=num}
	{foreach from=$product.images item=img}
	  {if $img.rank > 1 || #sec_img_include_first# == 'y'}
	  {if ($num mod $cols) == 0}
		<tr>
	  {/if}
<td align="center">
	<a href="#" onClick="imgChg({$img.large})"><img src="{$img.thumbnail}" id="{$img.thumbnail}" name="{$img.thumbnail}" width="50px" height="50px"></a>
</td>
  {if ($num mod $cols) == $cols-1}
	</tr>
  {/if}
 {counter assign=num}
 {/if}
 {/foreach}
		
   {math equation="y % x" y=$num x=$cols assign=md}
   {if $md != 0}
	 {section name=lp start=$md loop=$cols}
	   <td>&nbsp;
	   </td>
	 {/section}
	 </tr>
   {/if}
</table>
{/if}

I haven't written the script to swap the images yet. Therein lies my problem. Each product could have 0-5 alt images. So how do I account for an unknown number of images in the script? Every example I find has a static script and set image count and I don't know how to change that.


Thanks to all and anyone that can help!!!
Reply With Quote
  #2 (permalink)  
Old 02-16-10, 03:06 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,515
Thanks: 20
Thanked 109 Times in 106 Posts
Does it change in the database, or just for the page the person is viewing?

Looks like X-Cart.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP & MYSQL Same Table Ishmell PHP 7 06-28-09 11:36 PM
div css theighost CSS 11 09-14-08 02:30 AM
Image Swap issues spiffy337 JavaScript 3 10-05-06 12:34 PM
How can i do this image swap thing..? heki PHP 2 02-23-04 11:54 PM


All times are GMT -5. The time now is 02:00 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.