473,327 Members | 2,065 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

switch pic?

roN
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]
<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>
[/html]

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'
May 21 '06 #1
1 1252
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/
May 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Rudi Hansen | last post by:
I dont seem to be able to find the switch statement in Python. I would like to be able to do switch(var) case 1 : print "var = 1" case 2: print "var = 2"
10
by: Myster Ious | last post by:
Polymorphism replaces switch statements, making the code more compact/readable/maintainable/OO whatever, fine! What I understand, that needs to be done at the programming level, is this: a...
5
by: Bryan Parkoff | last post by:
C++ programmers and I tried to experience by writing 65536 switch cases. It is too large for Windows XP and other operating system to handle. It looks like that JMP Table obtains 256K bytes for...
10
by: clueless_google | last post by:
hello. i've been beating my head against a wall over this for too long. setting the variables 'z' or 'y' to differing numbers, the following 'if/else' code snippet works fine; however, the ...
65
by: He Shiming | last post by:
Hi, I just wrote a function that has over 200 "cases" wrapped in a "switch" statement. I'm wondering if there are performance issues in such implementation. Do I need to optimize it some way? ...
3
by: pgraeve | last post by:
I am a convert from VB to C# so bear with me on this "conversion" question C# switch statement seems to be the closest relative to VB's Select Case. I used VB's Select Case statement liberally. ...
11
by: ME | last post by:
In C# the following code generates a compiler error ("A constant value is expected"): public void Test(string value) { switch (value) { case SimpleEnum.One.ToString(): MessageBox.Show("Test...
12
by: | last post by:
Is it fine to call another method from Switch? Eg. Switch (stringVar) { case ("a"): somVar = "whatever"; Another_Method(); //call another method return;
7
by: Rohit | last post by:
Hi, I am working on a switch module which after reading voltage through a port pin and caterogizing it into three ranges(open,low or high), passes this range to a function switch_status() with...
11
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
Can switch statements be nested? I've got a large routine that runs off of a switch statement. If one of the switches in switch #1 is true, that enters switch statement #2. Some of the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.