日期:2014-05-16  浏览次数:20350 次

jsp页面中文本框,下拉框,单选框,复选框,文本域的清空
[/align][align=center]
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
   
    <title>缓存技术的应用</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">   
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

<script type="text/javascript">

//清空查询条件
function clearForm(){
    
document.getElementById('name').value="";
document.getElementById('sex').value="";
document.getElementById('textfield').value="";

//清空单选和复选框
var checked = checked || false;
var objects = document.getElementsByTagName("input");            //拿到input的值
for(var i=0;i<objects.length;i++){
if(objects[i].type=='radio' || objects[i].type=='checkbox'){ //判断类型
  if(checked==true)
objects[i].checked="checked";
else
objects[i].checked="";
}
}


}
</script>

  </head>
 
  <body>
  <center>
  <form action="" name="fm" method="post">
    <table border="1">
               <tr>
               <td colspan="2" align="center">缓存的应用</td>
               </tr>
       <tr>
<td>
姓名:</td>
<td>
<input name="name" type="text"  value=""/>
</td>
</tr>
<tr>
  <td>性别:</td>
  <td>
  <select name="sex">
  <option value="">请选择</option>
    <option value="男">男</option>
    <option value="女">女</option>
      </select></td>
  </tr>
  <tr>
<td>
单位类型:
</td>
<td>
&nbsp;<input type="radio" value="1" name="unittype"/>管理部门
&nbsp;<input type="radio" value="2" name="unittype"/>普通企业
</td>
</tr>
<tr>
<td>常用语言:</td>
<td>
&nbsp;
    <input type="checkbox" name="name2">java
    <input type="checkbox" name="name2">php
    <input type="checkbox" name="name2">c++<br>

</td>
</tr>
<tr>
    <td>
兴趣爱好:
</td>
<td>
<textarea name="textfield" id="textfield"></textarea>

</td>
</tr>
<t