Click to See Complete Forum and Search --> : switch statement - simple question


jslady
05-14-2003, 06:39 AM
hi,

The switch statement below only returns the default case label. When i input the number "100" into the prompt, i still get the instructions for the default.

Is the switch statement just not flexible work like this, or have i missed something out.

thanks.


<html><head>
<script language="javascript">
var answer = prompt ("gimme number","");
var testme ="";

switch (testme){

case 100: {
document.write ("this is the 100");
break;
}

default: {
document.write ("this is the default");
}

}// close the switch
</script>

</head><body></body></html>

khalidali63
05-14-2003, 06:44 AM
Use the following script

var answer = prompt ("gimme number","");
switch (answer){
case '100':
document.write ("this is the 100");
break;
default:
document.write ("this is the default");
break;
}// close the switch

jslady
05-14-2003, 06:47 AM
thanks Khalid,

this works fine.

cheers.

khalidali63
05-14-2003, 06:56 AM
you are welcome..
:D