Hi I’m trying to add another variable to this code using the Case statement:
[QUOTE]
<script>
function convert() {
var first = document.getElementsByName( “first”)[0],
second = document.getElementsByName( “second”)[0];
first.value = first.value.replace( /s/g, “”);
second.value = “Nice “+ first.value +” color”;
switch(first.value){
case ‘blue’:
case ‘green’:
case ‘red’:
return true;
break;
default:
return confirm(second.value + “?nnAre you serious?”);
break;
}
}
</script>
<form name= “execute” onsubmit=’return convert();’>
<input name=’first’ type=’text’ /> <input name=’second’ type=’hidden’ />
<input type=’submit’ value=”Execute” />
</form>
So for instance if you typed in ‘purple’ and only ‘purple’ it submits:
[QUOTE]
second.value = “Horrible “+ first.value +” color!”;
Wherever I put this code it doesn’t work. I’ve also added this before the default:
[QUOTE]
break;
case ‘purple’:
return true;
break;
It’s probably something really simple I’m missing. Any help would be great.
Thanks