Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > switch pic?

Reply
Thread Tools

switch pic?

 
 
roN
Guest
Posts: n/a
 
      05-20-2006
Hi,

I have 3 small images and 3 big images, i would like to display the big one,
when the small one is clicked, I tried:
[js]
IA1 = new Image();
IA1.src = "./images/IA-demo-big_1.jpg"; /* first big IA image */
IA2 = new Image();
IA2.src = "./images/IA-demo-big_2.jpg"; /* second big IA image */
IA3 = new Image();
IA3.src = "./images/IA-demo-big_3.jpg"; /* third big IA image */
function switchpic(pic)
{
window.document.images['big'].src = IA[pic].src;
}
[/js]
HTML Code:
<td width="23%"><a href="#"
OnClick="switchpic(1)"><img src="images/IA-demo-small_1.jpg" width="63"
height="95" border="0"></a></td>
<td colspan="3" rowspan="3"><img
src="images/IA-demo-big_3.jpg" name="big" width="193" height="290"></td>
</tr>
<tr>
<td><a href="#" OnClick="switchpic(2)"><img
src="images/IA-demo-small_2.jpg" width="63" height="95"
border="0"></a></td>
</tr>
<tr>
<td><a href="#" OnClick="switchpic(3)"><img
src="images/IA-demo-small_3.jpg" width="63" height="95"
border="0"></a></td>
</tr>
but it wouldn't work, why not?
I'd appreciate your help!
Thank you!
--
chEErs roN

I'm root, I'm allowed to do this!
keep on rockin'
 
Reply With Quote
 
 
 
 
Randy Webb
Guest
Posts: n/a
 
      05-20-2006
roN said the following on 5/20/2006 5:08 PM:
> Hi,
>
> I have 3 small images and 3 big images, i would like to display the big one,
> when the small one is clicked, I tried:
> [js]
> IA1 = new Image();
> IA1.src = "./images/IA-demo-big_1.jpg"; /* first big IA image */
> IA2 = new Image();
> IA2.src = "./images/IA-demo-big_2.jpg"; /* second big IA image */
> IA3 = new Image();
> IA3.src = "./images/IA-demo-big_3.jpg"; /* third big IA image */
> function switchpic(pic)
> {
> window.document.images['big'].src = IA[pic].src;
> }


IA is not an array so you can't access it like that. Either make IA an
array or use window['IA' + pic].src;

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
trunking between Cisco Catalyst 500 switch and other type of switch jshubo@yahoo.com Cisco 3 01-19-2008 12:10 AM
Switch/Switch problem fibre gigbit ethernet hartmut.albers@gmail.com Cisco 2 09-06-2005 04:59 PM
Is a frame switch and an ISDN switch really needed? owmanstubbedmytoe Cisco 2 12-05-2004 07:15 AM
bridge / layer 2 switch / layer 3 switch Joel M. Baldwin Cisco 2 11-06-2003 11:19 PM
difference b/w layer 2 switch and layer 3 switch praveen Cisco 1 10-22-2003 07:19 AM



Advertisments