請有人可以幫我做一個switch語句與形式的代碼來檢查 類似:在JavaScript中表格數
<script language="JavaScript">
<!--
function verifyPerf(form){
var myEntry = form.number(); //check the edit box number, didn't know how?!
var firstPart = "1. You need to do thing 1";
var endPart = "2. You need to to do thing 2";
switch(myEntry){
case "<= 3000" :
alert(firstPart);
break;
case ">3000 and <9000" :
alert(endPart);
break;
//would like to add 3 more cases
default :
alert('You have entered an invalid performance number');
}
}
-->
</script>
</head>
<body>
<form name="myForm">
<b>Please enter your performance number:</b><br>
<input type=number value="" name="perfNumber">
<input type=BUTTON value="Verify" name="myButton" onClick='verifyPerf(this.form)'>
</form>
</body>
</html>
感謝您的幫助。 Lx
還有這個零件不起作用。 function verifyPerf(form){var myEntry = form.value;
..... 和形式:
請輸入性能:
這不是'switch'的設計目的,它是'if(){} else if(){}/* etc */else {}'的設計目的。 –