Checkbox取值方法

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title>无标题文档</title>

</head>

<body>

<script>

function check(){

var num=0;

for(var i=0;i<document.form1.checkbox.length;i++){

if(document.form1.checkbox[i].checked){

num+=1;

}

}

if(num>0){

  if(num==1){

  span1.innerText="选了一个"

  }

  else if(num==2){

  span1.innerText="选了两个!"

  }

  else{

  span1.innerText="超过了两个!"

  }

  document.form1.move.disabled=false

return false;

}

else{

document.form1.move.value="0"

document.form1.move.disabled=true

alert("没有选择!");

span1.innerText=""

return false;

}

}

</script>

<form method="post" action="trim.asp">

 

  <select >

  <option value="0">请选择目标文件夹:</option>

  <option value="1">1</option>

  <option value="2">2</option>

  <option value="3">3</option>

  <option value="4">4</option>

  </select>

  <p>

    <input type="checkbox" value="football" />

  football</p>

  <p>

    <input type="checkbox" value="basketball" />

    basketball  </p>

  <p>

    <input type="checkbox" value="volleyball"  />

  volleyball</p>

  <span ></span>

  <p>

    <input type="submit" value="提交" />

  </p>

</form>

</body>

</html>

trim.asp

  <%
  a=split(request("checkbox"),",")
  for i=0 to ubound(a)
  sql="select *from ball where ballname='"&trim(a(i))&"'" & "<br/>"
  response.write sql
  next
  %>
 
  <br />
 
  <%
  for i=1 to request("checkbox").count
  sql="select *from ball where ballname='"&request("checkbox")(i)&"'" & "<br/>"
  response.write sql
  next
  %>
 
  <br/>
 
  <%
  for each item in request("checkbox")
  sql="select *from ball where ballname='"&item&"'" & "<br/>"
  response.write sql
  next
  %>

    A+
发布日期:2007年04月03日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: