SSH jsp获取checkobx,radio的值,并传递到后台的实现方法

这几天弄一个SSH的小项目,有一个问卷调查模块,一开始没想到怎么获取checkbox和radio的值然后传到后台,后来试了一下,发现直接把checkbox\radio放在form里。相应的name设置为属性值,后台可以直接获取。代码如下。


<%@ page language="java" contentType="text/html; charset=utf-8"

    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>风险评估</title>
<script type="text/javascript">

//进入这个jsp页面时的提示信息
 function prompt(){
 var r=confirm("请注意!\u000d我们会收集您的基本信息,以保证评估质量。\u000d并且请您在填写问卷时务必根据真实情况回答。");
  if (r==true){}
else{history.back(-1);}}





//检查是否取到值了
function getRadioValue(radionObj)  
{  
    for(var i = 0; i < radionObj.length; i ++)      
    {          
        if (radionObj[i].checked)   
        {  
            str=radionObj[i].value;  
alert(str);
        }  
    }  
  
    return str;  

}  
function getCheckboxValue(CheckboxObj){
for(var i = 0; i < CheckboxObj.length; i ++)      
    {          
        if (CheckboxObj[i].checked)   
        {  
            str=CheckboxObj[i].value;  
        }  
    }  
    return str;  

}


</script>


<style>
body { margin: 0; }
a { color: #225592; text-decoration: none; }
.content { width: 800px; margin: 0 300px; }
.vote { display: block; margin-left: 40px; float: left; }
.votechoice { padding-top: 20px; }
.votechoice input { float: left; }
.votechoice ul { list-style-type: none; padding-top: 10px; }
.votechoice ul li { width: 100%; float: left; padding-top: 15px; margin-left: 20px; }
.votechoicename { display: block; width: 340px; padding-left: 25px; }
.button { width: 80px; line-height: 25px; text-align: center; font-size: 18px; font-weight: bold; color: #ffffff; text-shadow: 1px 1px 1px #333; border-radius: 5px; margin: 0 20px 20px 0; position: relative; overflow: hidden; border: 1px solid #1e7db9; background-color: #2e88c0; box-shadow: 0 1px 2px #8fcaee inset, 0 -1px 0 #497897 inset, 0 -2px 3px #8fcaee inset; background: -webkit-linear-gradient(top, #42a4e0, #2e88c0); background: -moz-linear-gradient(top, #42a4e0, #2e88c0); background: linear-gradient(top, #42a4e0, #2e88c0); }
</style>




<style type="text/css">
table.hovertable {
font-family: verdana,arial,sans-serif;
font-size:11px;
color:#333333;
border-width: 1px;
border-color: #999999;
border-collapse: collapse;
}


}
table.hovertable tr {
background-color:#d4e3e5;
}
table.hovertable td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #a9c6c9;
}
h1 {
    color: #292929;
    font-family: "Trebuchet MS",Lucida,Verdana,sans-serif;
    font-weight: normal;
}


button {
  display: inline-block;
  padding: 15px 25px;
  font-size: 24px;
  cursor: pointer;
  text-align: center;   
  text-decoration: none;
  outline: none;
  color: #fff;
  background-color: #00EEEE;
  border: none;
  border-radius: 15px;
  box-shadow: 0 9px #999;
}


</style>


</head>
<body οnlοad="prompt();">  
<table class="hovertable" style="position:relative;width:500px;height:200px;top:50px;" align="center">
   <tr οnmοuseοver="this.style.backgroundColor='#ffff66';" οnmοuseοut="
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值