<!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">
<script language="javascript">
function selectIt(action,ckName){
    var testform=document.getElementsByName(ckName);
    for(var i=0 ;i<testform.length;i++){
        if(testform[i].type=="checkbox"){
            e=testform[i];
            e.checked=(action=="selectAll")?1:(action=="clear"?0:(!e.checked));
        }
    }    
}
/*
function selectIt(action){
    var testform=document.getElementById("bdkey");
    for(var i=0 ;i<testform.elements.length;i++){
        if(testform.elements[i].type=="checkbox"){
            e=testform.elements[i];
            e.checked=(action=="selectAll")?1:(!e.checked);
        }
    }    
}
*/
</script>
 <link rel="stylesheet" type="text/css" href="main.css">
</head>
<body> <a href="#" onClick="selectIt('selectAll','interests')">全选</a> <input type="checkbox" name="invest" value="checkbox" onClick="selectIt('reverse','interests')">反 选
<input type="checkbox" name="invest" value="checkbox" onClick="selectIt('clear','interests')">全清
 
<form name="bdkey" id="bdkey"  method="post" action="servlet/Processor"> <input type="submit" value="确定" name="submit">
<p class="STYLE1">你关注的领域:<br></p><p class="STYLE1"><input type="checkbox" name="interests" value="java">Java语言&nbsp; <input type="checkbox" name="interests" value="ERP">ERP&nbsp; <input type="checkbox" name="interests" value="电子商务">电子商务&nbsp; 
<input type="checkbox" name="interests" value="数据库">数据库 &nbsp; <input type="checkbox" name="interests" value="计算机网络">计算机网络&nbsp;&nbsp;&nbsp; 其它:<input type="text" size="20" name="interests"> 
 
</p></form>
</body>

</html>


Servlet 的doPost( )方法中加入如下代码:
String[] interest=request.getParameterValues("interests");
  StringBuffer s=new StringBuffer();
  if(interest==null||interest.length<1){
   
  }else{
   for (int i=0;i<interest.length;i++){
    s.append(interest[i]+":");
   }
   
   out.println("你的兴趣是:"+s);
  }

只有注册用户登录后才能发表评论。


网站导航:
 

posts - 2, comments - 0, trackbacks - 0, articles - 4

Copyright © 飞思达工作室