.innerhtmlを使用して、ボタンの上にエラーメッセージを入力しようとしています。私はこれを機能させるのに近づいていると思いますが、行き詰まっています。私はJSを初めて使用するので、非常に単純なセマンティックエラーがあると思います。
これが私のjsfiddleです:http://jsfiddle.net/ajX2U/
var sel = document.getElementById("stateType");
switch(sel.value) {
case "VA":
location.href = "http://www.test1.com";
break;
case "MD":
location.href = "http://www.test2.com";
break;
case "IL":
location.href = "http://www.test3.com";
break;
case "TX":
location.href = "http://www.test4.com";
break;
case "other":
location.href = "http://www.test5.com";
break;
// oh dear we have selected a wrong option
default:
document.getElementById('error').innerHTML = 'Fred Flinstone';
}
}