JavaScript中表格的应用

来源:互联网 发布:域名管理后台 编辑:程序博客网 时间:2024/06/05 16:24

<!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>
<style type="text/css">
<!--
td { text-align:left;}
-->
</style>

<script language="javascript">
 function cleck()
 {
  //验证*是否为空
  if(frm.username.value=="")
  {
    alert("姓名不能为空!");
  }
  else
     alert("姓名:"+frm.username.value)
  if(frm.userage.value=="")
  {
    alert("年龄不能为空!");
  }
else
   alert("年龄:"+frm.userage.value)
  if(frm.usercity.value=="")
  {
    alert("您所在的城市不能为空!");
  }
  else
   alert("所在城市:"+frm.usercity.value)
  if(frm.userphone.value=="")
  {
    alert("联系电话不能为空!");
  }
  else
   alert("联系电话:"+frm.userphone.value)
 if(frm.address.value=="")
  {
    alert("通讯地址不能为空!");
  }
 else
   alert("通讯地址:"+frm.addresse.value)
 }
</script>

</head>

<body>
<form name="frm">
<center>
<table border="1" cellpadding="1" cellspacing="1" >
<tr bgcolor="#66CCFF"><td colspan="2">基本资料</td></tr>

<tr>
<td align="right">姓名</td>
<td><input type="text" name="username" value="" > <font color="#FF0000" size="-1">*</font></td>
</tr>

<tr>
<td align="right">身份</td>
<td>
<input type="radio" name="身份" value="0" checked >在校教师
<input type="radio" name="身份" value="1"  >退休教师
<input type="radio" name="身份" value="2" >在校学生
</td>
</tr>

<tr>
<td align="right">年龄</td>
<td align="left">
<input type="text" name="userage"  value="" />岁<font color="#FF0000" size="-1">*</font></td>
</tr>

<tr>
<td align="right">经验</td>
<td>
<input type="text" id="userjingyan" />
</td>
</tr>

<tr>
<td align="right">您的学历</td>
<td>
<select name="userxueli">
<option id="学历" value="0">不限
<option id="学历" value="1" >大专
<option id="学历" value="2" >本科
<option id="学历" value="3" >硕士
<option id="学历" value="4" >博士

</select>
</td>
</tr>

<tr>
<td align="right">专业</td>
<td>
<select name="userzhuanye">
<option id="专业" value="0" selected>不限
<option id="专业" value="1" >计算机
<option id="专业" value="2" >电子技术
<option id="专业" value="3" >旅游专业
<option id="专业" value="4" >工程建设
<option id="专业" value="5" >体育
<option id="专业" value="6" >法律
</select>
</td>
</tr>

<tr>
<td align="right">您所在的城市</td>
<td>
<input type="text" name="usercity"  value=""/><font color="#FF0000" size="-1">*</font>
</td>
</tr>

<tr>
<td align="right">您的性别</td>
<td>
<input type="radio" name="sexm" value="0" checked >男
<input type="radio" name="sexw" value="1" >女
</td>
</tr>

<tr>
<td align="right">原教的科目</td>
<td>

   <input type="checkbox" name="books" value="0" checked />语文
   <input type="checkbox" name="books" value="1"  />数学
   <input type="checkbox" name="books" value="2"  />英语
   <input type="checkbox" name="books" value="3"  />物理
   <input type="checkbox" name="books" value="4" />化学
   <input type="checkbox" name="books" value="5"  />生物<br>
  
   <input type="checkbox" name="books1" value="0"  />政治
  <input type="checkbox" name="books1" value="1"  />历史
  <input type="checkbox" name="books1" value="2"  />地理
  <input type="checkbox" name="books1" value="3"  />音乐
  <input type="checkbox" name="books1" value="4"  />体育
  <input type="checkbox" name="books1" value="5"  />美术<br />
 
  <input type="checkbox" name="books2" value="0"  />计算机
<input type="checkbox" name="books2" value="1"  />成人高考
<input type="checkbox" name="books2" value="2"  />心理辅导
<input type="checkbox" name="books2" value="3"  />其他科目
</td>
</tr>

<tr>
<td align="right">要教的其它科目</td>
<td>
<input type="text" id="otherbook" />
</td>
</tr>

<tr>
<td align="right">联系电话</td>
<td>
<input type="text" id="userphone"  value=""/><font color="#FF0000" size="-1">*</font>
</td>
</tr>

<tr>
<td align="right">其它联系方式</td>
<td>
<input type="text" id="otherphone"  value=""/>
</td>
</tr>

<tr>
<td align="right">电子邮件</td>
<td>
<input type="text" id="email"  value=""/>
</td>
</tr>

<tr>
<td align="right">通讯地址</td>
<td>
<input type="text" name="address"  value=""/><font color="#FF0000" size="-1">*</font>
</td>
</tr>

<tr>
<td align="right">邮政编码</td>
<td>
<input type="text" id="code"  value=""/>
</td>
</tr>

<tr>
<td align="center" colspan="2">
<input type="submit" value="确定" onclick="cleck()" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="reset" value="重填"/>
</td>
</tr>
</table>
</center>
</form>
</body>
</html>