自写自看

checkbox选取值的获取

一:名称不同,值可相同  
      <input   type=checkbox   name="a1"   value="1">CPU  
      <input   type=checkbox   name="a2"   value="1">主板  
      <input   type=checkbox   name="a3"   value="1">内存  
  以名称为依据的判断:  
      request.getParameter("a1")==null  
   
  二:名称相同,值不同  
      <input   type=checkbox   name="a"   value="1">CPU  
      <input   type=checkbox   name="a"   value="2">主板  
      <input   type=checkbox   name="a"   value="3">内存  
  以值为依据的判断:  
      String[]   a   =   request.getParameterValues("a");  
      看a数组中是否有相应的值。如果选中"CPU",则a[0]="1"  

posted on 2006-11-04 00:49 昨夜人生 阅读(544) 评论(0)  编辑  收藏


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


网站导航: