...

View Full Version : Anything wrong with this switch?



okendoze
08-22-2008, 11:35 PM
I have this switch in a function that is called by an event. I don't see anything wrong with it, but when I add it to a script that's already in the head section of the page, all of the page's event functions give me errors. So without this switch, everything works, and with the switch, nothing works. Where's my error?



function evaluateoption()
{
switch()
{
case 10:
choose10();
break;
case 13:
choose13();
break;
case 14:
choose14();
break;
case 21:
choose21();
break;
case 30:
choose30();
break;
case 38:
choose38();
break;
case 43:
choose43();
break;
case 44:
choose44();
break;
case 47:
choose47();
break;
case 51:
choose51();
break;
case 57:
choose57();
break;
case 62:
choose62();
break;
case 72:
choose72();
break;
case 73:
choose73();
break;
case 81:
choose81();
break;
case 99:
choose99();
break;
case 103:
choose103();
break;
case 105:
choose105();
break;
case 107:
choose107();
break;
case 138:
choose138();
break;
case 150:
choose150();
break;
case 153:
choose153();
break;
case 160:
choose160();
break;
case 167:
choose167();
break;
case 170:
choose170();
break;
case 171:
choose171();
break;
case 176:
choose176();
break;
case 195:
choose195();
break;
case 203:
choose203();
break;
case 204:
choose204();
break;
case 215:
choose215();
break;
case 222:
choose222();
break;
case 223:
choose223();
break;
case 225:
choose225();
break;
case 229:
choose229();
break;
}
}

ninnypants
08-22-2008, 11:50 PM
You need something to compare the cases to

switch()// put something in the parentheses like a variable

okendoze
08-23-2008, 12:03 AM
Suppose I put a dead variable like switch(x) where x isn't defined and the following in the HTML:



<select name="list" onchange="evaluateoption(this.value);">
<option value="10">Number 10</option>
<option value="13">Number 13</option>
</select>


Would that work?

ninnypants
08-23-2008, 12:19 AM
Yeah it should as long as your function looks like this


function evaluateoption(x)
{
switch(x)

okendoze
08-23-2008, 01:21 AM
That solved it. Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum