急~请高手帮忙~asp 判断表单中一个单选钮是否被选中的问题
来源:百度知道 编辑:UC知道 时间:2024/05/20 17:31:01
在一个表单中,必须选择一个指定的单选钮(同意按钮)才能进行下一步的操作。
说明:如果此按钮没有被选中,则出现文字提示“操作失败”;若此按钮被选中,则页面转到另一个新的页面。
单选钮的详细属性:
<label>
<input type="radio" name="agree" value="是" />同意
</label>
<label>
<input type="radio" name="agree" value="否" />不同意
说明:如果此按钮没有被选中,则出现文字提示“操作失败”;若此按钮被选中,则页面转到另一个新的页面。
单选钮的详细属性:
<label>
<input type="radio" name="agree" value="是" />同意
</label>
<label>
<input type="radio" name="agree" value="否" />不同意
你这两个单选打开页面的时候是两个都没有选中的
可以这样判断:
<script>
function checkageree(){
if(document.getElementById("agree").value==""){
alert("请选择同意或者不同意!");
return flase;
}else{
if(document.getElementById("agree").value=="否") {
window.alert("操作失败!");
return false;
}else{
return true;
}
}
}
</script>
用javascript来判断即可。if(document.form1.agree.value=="是"){。。。。。。}
加个JS判断一下就好了。
<script type="text/javascript">
<!--//
function checkagree() {
if(window.document.getElementById("agree").value=='否') {
window.alert("操作失败!");
return false;
}
}
-->
</script>
触发按钮的事件用:onclick="javascript:return checkagree();"