Switch problem

A

Andre

Hi,

I have some function to Preload images and make MouseOver etc..

But when a put a Switch statement in one of my function (MouseOver), a
receive an error on body load in my preload function.. did someone have any
idea why ?

Here's my switch code :

function setOver(num)
{
var txt;
obj = eval('document.getElementById("image' + num + '")');
obj.src = imagesHover[num-1];

txt = '<img src="' + imagesInfo[num-1] + '">';
document.all("infoDiv").innerHTML=txt;
document.all["infoDiv"].style.display='block';

Switch (num)
{
Case 1: alert(num);Break;
Default: alert("hello");Break;
}
}



Thank you.
 
C

Christopher Benson-Manica

Andre said:
Switch (num)
{
Case 1: alert(num);Break;
Default: alert("hello");Break;
}

switch( num ) {
case 1:
alert( num );
break;
default:
alert( "hello" );
break;
}

Notice the differences in case; JavaScript is case-sensitive.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top