Switch problem

Discussion in 'Javascript' started by Andre, Oct 4, 2004.

  1. Andre

    Andre Guest

    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.
    Andre, Oct 4, 2004
    #1
    1. Advertising

  2. Andre

    Andre Guest

    i forgot to tell that everyting is working fine before i put the Switch !!


    "Andre" <> a écrit dans le message de
    news:kUf8d.3399$...
    > 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.
    >
    >
    >
    Andre, Oct 4, 2004
    #2
    1. Advertising

  3. Andre <> spoke thus:

    > 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.

    --
    Christopher Benson-Manica | I *should* know what I'm talking about - if I
    ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
    Christopher Benson-Manica, Oct 4, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mikael Östberg
    Replies:
    5
    Views:
    447
    Kevin Spencer
    Oct 22, 2005
  2. Christian Seberino
    Replies:
    0
    Views:
    290
    Christian Seberino
    Oct 21, 2003
  3. Chih-Hsu Yen

    Switch-case problem

    Chih-Hsu Yen, Apr 12, 2005, in forum: C Programming
    Replies:
    10
    Views:
    562
    Chih-Hsu Yen
    Apr 13, 2005
  4. onkar

    switch problem - interesting !!

    onkar, Dec 15, 2006, in forum: C Programming
    Replies:
    1
    Views:
    228
    Richard Heathfield
    Dec 15, 2006
  5. Switch Within A Switch

    , Apr 22, 2006, in forum: Javascript
    Replies:
    7
    Views:
    100
    Lasse Reichstein Nielsen
    Apr 22, 2006
Loading...

Share This Page