
jsp单选框和复选框(checkbox和radio),在发送时,判断是否已经选择,未选择不发送 20
<head><metahttp-equiv="Content-Type"content="text/html;charset=utf-8"><title>发送</titl...
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>发送</title></head> <body><style>p.ziti{ font-family:"微软雅黑体"; }</style><div style="height:2px;border-bottom:1px #ccc solid;"></div><p class="ziti" align="center" style="color:#F75000">发送</p><div style="height:2px;border-bottom:1px #ccc solid;"></div><form action="<%=path%>/TaskServlet" method="post"><!--提交方法的jsp --> <div align="center"> <div class='line'> <br /> <div align="center">请选择方案: </br></br> <input type="radio" name="fanganmiaoshu" value="空气。" id="fanganmiaoshu"> <label for="sexMale">方案一</label> <input type="radio" name="fanganmiaoshu" value="形成" id="fanganmiaoshu"> <label for="sexFemale">方案二</label> <input type="radio" name="fanganmiaoshu" value="利用" id="fanganmiaoshu"> <label for="sexFemale">方案三</label> <br/><br/> </div> <br /> </div> <br /> <div class='line'> <div align="center">请选择队伍: </br></br> <input type="checkbox" name="team" value="一小队" /> 一小队 <input type="checkbox" name="team" value="二小队" /> 二小队 <input type="checkbox" name="team" value="三小队" /> 三小队<br/><br/> <input type="checkbox" name="team" value="四小队" /> 四小队 <input type="checkbox" name="team" value="五小队" /> 五小队 </div> <br /> </div> </br> <div class='line'> <div align="left" class='leftDiv'></br> 备注:</div><br/> <center> <div align="center" class='rightDiv'> <textarea name="beizhu" rows="8" style="width:400px; "> </textarea> </div> </center> </div> <div class='line'> <div align="center"> <br/><input type="submit" value="发送命令" style='font-size:15px' onclick="return checkform(this.form);" /> <input type="reset" value="重置内容" style='font-size:15px'/><br/> </div> </div></br></div></form> </body></html>
展开
展开全部
function checkform(frm){
var team = frm.team;
var teamVal = new Array();
for(var i = 0; i < team.length; i++)
if(team[i].checked)
teamVal.push(team[i].value);
if(frm.fanganmiaoshu.value && teamVal.length > 0)
{
//有值
return true;
}
else
{
return false;
}
}
var team = frm.team;
var teamVal = new Array();
for(var i = 0; i < team.length; i++)
if(team[i].checked)
teamVal.push(team[i].value);
if(frm.fanganmiaoshu.value && teamVal.length > 0)
{
//有值
return true;
}
else
{
return false;
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询