Switch problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andre

    Switch problem

    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("i nfoDiv").innerH TML=txt;
    document.all["infoDiv"].style.display= 'block';

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



    Thank you.



  • Andre

    #2
    Re: Switch problem

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


    "Andre" <webmaster@cabl evision.qc.ca> a écrit dans le message de
    news:kUf8d.3399 $HO1.193508@new s20.bellglobal. com...[color=blue]
    > 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[/color]
    any[color=blue]
    > 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("i nfoDiv").innerH TML=txt;
    > document.all["infoDiv"].style.display= 'block';
    >
    > Switch (num)
    > {
    > Case 1: alert(num);Brea k;
    > Default: alert("hello"); Break;
    > }
    > }
    >
    >
    >
    > Thank you.
    >
    >
    >[/color]


    Comment

    • Christopher Benson-Manica

      #3
      Re: Switch problem

      Andre <webmaster@cabl evision.qc.ca> spoke thus:
      [color=blue]
      > Switch (num)
      > {
      > Case 1: alert(num);Brea k;
      > Default: alert("hello"); Break;
      > }[/color]

      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)cybers pace.org | don't, I need to know. Flames welcome.

      Comment

      Working...