|
Java学习者论坛
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type="text/javascript">
<br>function submitclick(){
<br>var selF=seleck("cbx");
<br>if(selF==0){alert("你没有選择水果");return false; }
<br>else{
<br>var selR=seleck("radio");
<br>if(selR==0){alert("請做出购買或不購买的选擇");return false;}
<br>else{
<br>var msg="你喜欢的水果有:"+selF;
<br>msg=msg+",而且你做了"selR"选择";
<br>alert(msg);
<br>return msg;
}
}
}
<br>function seleck(objName){
<br>var obj=document.getElementsByName(objName);
<br>var selArray=new Array();
<br>for(var i=0;i<obj.length;i++){
<br>if(obj.checked){
<br>selArray=obj.value;
}
}
<br>return selArray;
}
<br></script>
</head>
<body>
<form action="">
你喜欢的水果有?
<input type="checkbox" name=cbx value="apple">蘋果
<input type="checkbox" name=cbx value="orange">橘子
<input type="checkbox" name=cbx value="peach">桃子
選择操作:
<input type="radio" name=radio value="buy">購买
<input type="radio" name=radio value="nobuy">不购买
<input type="submit" name="bsubmit" value="提交" onclick=javascript:submitClick()>
<input type="reset" name="reset" value="重写">
</form>
</body>
</html>
这個有什么错误,为什么不能運行JS?
欢迎来到Java学習者论壇,转载请注明地址:http://www.javaxxz.com. |
|