网站地图    收藏   

主页 > 前端 > css教程 >

两个select级联操作实例(教师职称类型与职称)

来源:自学PHP网    时间:2015-04-14 14:51 作者: 阅读:

[导读] !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//ENhtmlheadtitleMy JSP #39;mylist_liti.jsp#39; starting page/title script language=javascript var cate......

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>My JSP 'mylist_liti.jsp' starting page</title>
    <script language="javascript">

 var cateArray = new Array();

  cateArray[cateArray.length]=new Array("1","教师系列");
  cateArray[cateArray.length]=new Array("2","工程师系列");
  cateArray[cateArray.length]=new Array("3","实验系列");
  cateArray[cateArray.length]=new Array("4","研究员系列");
  
 var titleArray = new Array();

  titleArray[titleArray.length]=new Array("1","教授","教授");
  titleArray[titleArray.length]=new Array("1","副教授","副教授");
  titleArray[titleArray.length]=new Array("1","讲师","讲师");
  titleArray[titleArray.length]=new Array("1","助教","助教");
   
  titleArray[titleArray.length]=new Array("2","教授级高工","教授级高工");
  titleArray[titleArray.length]=new Array("2","高级工程师","高级工程师");
  titleArray[titleArray.length]=new Array("2","工程师","工程师");
  titleArray[titleArray.length]=new Array("2","助工","助工");
  
  titleArray[titleArray.length]=new Array("3","教授级高级实验师","教授级高级实验师");
  titleArray[titleArray.length]=new Array("3","高级实验师","高级实验师");
  titleArray[titleArray.length]=new Array("3","实验师","实验师");
  titleArray[titleArray.length]=new Array("3","助理实验师","助理实验师");
  
  titleArray[titleArray.length]=new Array("4","研究员","研究员");
  titleArray[titleArray.length]=new Array("4","副研究员","副研究员");
  titleArray[titleArray.length]=new Array("4","助理研究员","助理研究员");
  titleArray[titleArray.length]=new Array("4","实习研究员","实习研究员");

 function setTitle(obj1ID,obj2ID){
        var objCate = document.getElementById(obj1ID);
        var objTitle = document.getElementById(obj2ID);
        var i;
        var itemArray = null;
        if(objCate.value.length > 0){
             itemArray = new Array();
             for(i=0;i<titleArray.length;i++){
                if(titleArray[i][0]==objCate.value){
                    itemArray[itemArray.length]=new Array(titleArray[i][1],titleArray[i][2]);
                }
             }
        }
        for(i = objTitle.options.length ; i >= 0 ; i--){
                objTitle.options[i] = null;
        }
        objTitle.options[0] = new Option("请选择职称");
        objTitle.options[0].value = "";
        if(itemArray != null){
                for(i = 0 ; i < itemArray.length; i++){
                        objTitle.options[i+1] = new Option(itemArray[i][1]);
                        if(itemArray[i][0] != null){
                           objTitle.options[i].value = itemArray[i][0];
                        }
                }
        }

   } 
</script>
	</head>

	<body
		style="background: url(${ctx }/images/iframe_bg.gif) repeat-x; margin: 2px;">

	

		<div id="create"
			style="border: 1px solid #84a1bd; margin: 10px 250px; ">
			<form name="createForm"
				action="${ctx}/sys/tea.do?method=createTea" method="post">
				<table width="60%" align="center" cellpadding="0" cellspacing="0"
					style="font-size: 13px;">
					<tr>
						<td colspan="2" align="center">
						<br/>
							新增教师用户
						</td>
					<tr>
						<td align="center" width="28%" height="30">
							教师编号
						</td>
						<td align="left">
							&nbsp;&nbsp;
							<input type="text" name="number" />

						</td>
					</tr>
					<tr>
						<td align="center" width="28%" height="30">
							教师姓名
						</td>
						<td align="left">
							&nbsp;&nbsp;
							<input type="text" name="name" />

						</td>
					</tr>
					<tr>
						<td align="center" width="28%" height="30">
							职称类型
						</td>
						<td align="left">
							&nbsp;&nbsp;
							<select name="cateid" id="cateid" onChange="setTitle('cateid','titleid')">
								 <option value="">请选职称类型</option>
								<option value="1" >
									教师系列
								</option>
								<option value="2">
									工程师系列
								</option>
								<option value="3">
									实验系列
								</option>
								<option value="4">
									研究员系列
								</option>
							</select>

						</td>
					</tr>
					<tr>
						<td align="center" width="28%" height="30">
							职 &nbsp;&nbsp;&nbsp;&nbsp;称
						</td>
						<td align="left">
							&nbsp;&nbsp;
							<select name="title" id="titleid">
								<option value="暂无">
									请选职称
								</option>
							</select>

						</td>
					</tr>
					
					<tr>
						<td align="center" width="28%" height="30">
							&nbsp;
						</td>
						<td align="left">
							&nbsp;&nbsp;

							<a href="javascript:document.createForm.submit();">新增</a>
							&nbsp;&nbsp;
							
						</td>
					</tr>
				</table>
			</form>
		</div>

		<br />
	</body>
</html>

 

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论