Click to See Complete Forum and Search --> : switch + case question


melina
02-03-2003, 03:30 PM
Hello,
i have the following code:
function xroma (varibel1, varible2,varible3,farbe){
switch (farbe)
{
case 1:
mycolor = #000000;
break;
case 2:
mycolor = #ffffff;
break;
case 3
mycolor = #cccccc;
break;
}
paint([...],mycolor);
}
i get an error : expected label for break.
I am just getting started with javascript so if antbody could help and tell me what i am doing wrong here, this would be nice.
Thanks

Sergey Smirnov
02-03-2003, 04:56 PM
1. colon is missing after "case 3"

2. Use quotes for colors.
I.e. mycolor = "#000000";

melina
02-03-2003, 05:05 PM
Thanks for your reply.

I fixed it:
switch (farbe)
{
case 1:
mycolor = "#000000";
break;
case 2:
mycolor = "#ffffff";
break;
case 3:
mycolor = "#cccccc";
break;
}

but still getting the same error when debbuging:
Error 1013 expected label for break
Any suggestions what else could be wrong?

Sergey Smirnov
02-03-2003, 05:19 PM
Now, "switch" is correct. I tested it.
The problem could be outsite this statment.

melina
02-03-2003, 05:34 PM
Strange...i tested it online and everything is working fine, when having it in DW the error message appears(without having changed anything, is exactly what i tested online).So there might be something wrong with my system and not with the script itself...:)...i will check it out.

Thanks for helping!