出发chkcz()函数的是select菜单中的onchange(),现在存在的错误是,switch无效,总是执行 default:结果
- HTML code
<select name="btype" id="btype" onchange="chkcz()"> <option selected="selected">请选择</option> <option value="3D">3D</option> <option value="2B">2B</option> <option value="367">367</option> <option value="265">265</option> </select>
- JScript code
function chkcz() { var czs=document.form1.btype.value; switch (czs) { case '3D': document.form1.award12.value='1000'; document.form1.award22.value=''; document.form1.award32.value=''; document.form1.award42.value=''; document.form1.award52.value=''; document.form1.award62.value=''; document.form1.award72.value=''; case '2B': document.form1.award12.value='5,000,000'; document.form1.award22.value=''; document.form1.award32.value='3000'; document.form1.award42.value='200'; document.form1.award52.value='10'; document.form1.award62.value='5'; document.form1.award72.value=''; case '367': document.form1.award12.value=''; document.form1.award22.value=''; document.form1.award32.value=''; document.form1.award42.value='500'; document.form1.award52.value='100'; document.form1.award62.value='10'; document.form1.award72.value='46'; case '265': document.form1.award12.value=''; document.form1.award22.value='50'; document.form1.award32.value=''; document.form1.award42.value=''; document.form1.award52.value=''; document.form1.award62.value=''; document.form1.award72.value=''; default: document.form1.award12.value=''; document.form1.award22.value=''; document.form1.award32.value=''; document.form1.award42.value=''; document.form1.award52.value=''; document.form1.award62.value=''; document.form1.award72.value=''; } } </script>
------解决方案--------------------
语法错误:
switch (czs) {
case '3D':
break;
case '2B':
break;
default :
break;
}
------解决方案--------------------
switch (czs) {
case '3D':
document.form1.award12.value='1000';
document.form1.award22.value='';
document.form1.award32.value='';
document.form1.award42.value='';
document.form1.award52.value='';
document.form1.award62.value='';
document.form1.award72.value='';
break;
case '2B':
document.form1.award12.value='5,000,000';
document.form1.award22.value='';
document.form1.award32.value='3000';
document.form1.award42.value='200';
document.form1.award52.value='10';
document.form1.award62.value='5';
document.form1.award72.value='';
break;
case '367':
document.form1.award12.value='';
document.form1.award22.value='';
document.form1.award32.value='';
document.form1.award42.value='500';
document.form1.award52.value='100';
document.form1.award62.value='10';
document.form1.award72.value='46';
break;
case '265':
document.form1.award12.value='';
document.form1.award22.value='50';