Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
169
rated 0 times [  171] [ 2]  / answers: 1 / hits: 28528  / 12 Years ago, fri, august 17, 2012, 12:00:00

I currently have the following code that replaces a big image when a thumbnail is clicked:



Javascript:



    img1 = new Image();
img1.src = '{$smarty.const.dir_images}/l_{$this_page.image1}';
img2 = new Image();
img2.src = '{$smarty.const.dir_images}/l_{$this_page.image2}';


Thumbnail HTML:



    <a href=javascript:document['mainimage'].src = img1.src; javascript:void(0);><img src={$smarty.const.dir_images}/t_{$this_page.image1} title= alt=/></a>
<a href=javascript:document['mainimage'].src = img2.src; javascript:void(0);><img src={$smarty.const.dir_images}/t_{$this_page.image2} title= alt=/></a>


Large Image HTML:



    <img id=mainimage name=mainimage src={$smarty.const.dir_images}/l_{$this_page.image1} title={$this_page.image1text} alt={$this_page.image1text} />


What I want to do is not only change the large image source when the thumbnail is clicked but the alt & title tags as well.



Thanks in advance


More From » html

 Answers
2

Try to use this way:



JavaScript



img1.alt=Image alt;
img1.title=Image title;


Thumbnail HTML:



<a href=javascript:document['mainimage'].src = img1.src;document['mainimage'].alt = img1.alt; document['mainimage'].title = img1.title; javascript:void(0);><img src={$smarty.const.dir_images}/t_{$this_page.image1} title= alt=/></a>

[#83584] Thursday, August 16, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ariel

Total Points: 523
Total Questions: 111
Total Answers: 100

Location: Anguilla
Member since Sun, Jan 29, 2023
1 Year ago
;