请教大侠:如何在一个form中存入多个二级联动菜单
sanshi5
![]()
|
1#
sanshi5 发表于2010-08-14
请教大侠:如何在一个form中存入多个二级联动菜单
<html>
<head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>员工薪资查询系统(测试版)</title> <style> <!-- a:link { text-decoration: none;} a:visited { text-decoration: none;} a:hover { text-decoration: none;} a:active { text-decoration: none;} body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; background-image: url(); } .style1 { FONT-SIZE: 12px; COLOR: #0000ff} .style2 { FONT-SIZE: 12px} .style3 { COLOR: #993399} .style5 {font-size: 14px} .style7 {font-size: 10px} .style8 {font-size: 12px} .style9 {COLOR: #ff0000;FONT-SIZE: 12px} .style11 {font-size: 14px; color: #CC0000;} .style12 {font-size: 16px} .style13 {FONT-SIZE: 12px} .style14 {font-size: 11px} .style15 { FONT-SIZE: 12px; COLOR: #cc0000;font-weight: bold} .style16 {font-size: 11px;font-weight: bold} .style17 {font-size: 12px;font-weight: bold} --> </style> </head> <body> <?php include("up.htm"); ?> <?php include("db_conn.php"); ?> <script language="javascript" src="wpcalendar.js"></script> <script> var gzcontent=""; function addTable() { var tableID=document.all.loop; var oRow=tableID.insertRow(tableID.rows.length); var oCell=oRow.insertCell(oRow.cells.length); oCell.innerHTML=gzcontent; } function initContent() { gzcontent=document.all.tb1.outerHTML; } </script> <script type="text/javascript"> function del(){ var mytable = document.getElementById("loop"); var rowlen=mytable.rows.length; var i=rowlen-1; mytable.deleteRow(i); } </script> <br> <form action="save_staff.php" method="post" name="frm"> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="1"> <tr><td><input type="button" value="增加一条"></td></tr> </table> <table align="center" id="loop" width="100%"> <tr> <td> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#3399FF" id="tb1"> <tr bgcolor="#FFFFFF"> <td align="center" class="style17" width="12%" height="29" colspan="2">身份证号码</td> <td align="center" class="style17" width="12%">出生日期</td> <td align="center" class="style17" width="10%">参加工作日期</td> <td align="center" class="style17" colspan="5">所属四级单位</td> <td align="center" class="style17" width="8%">调入本四级单位日期</td> <td align="center" class="style17" width="6%">操作</td> </tr> <tr bgcolor="#FFFFFF"> <td align="center" colspan="2"><input type="text" name=shenfenzheng[] size="20"></td> <td align="center"><INPUT type=text name=chushengri[] size="10" readonly></td> <? //注意:showCalendar(this)中的C一定得是大写?> <td align="center"><INPUT type=text name=gongzuori[] size="10" readonly></td> <? //注意:showCalendar(this)中的C一定得是大写?> <td align="center" colspan="5"> <?php class myconn{ var $conn; var $result; function myconn(){ $this->conn=mysql_connect('localhost','root',''); mysql_select_db('xinshui',$this->conn); } function process($sql){ mysql_query('set names gbk'); $result=mysql_query($sql); return $result; } } ?> <select name="s1"> <option selected>请选择</option> <?php $conn=new myconn(); $chang = "有限公司"; $sql="select * from danwei where lishu = '$chang' order by quancheng"; $result=$conn->process($sql); while($data=mysql_fetch_array($result)) { ?> <option value="<?php echo $data[1];?>"><?php echo $data[1];?></option> <?php } ?> </select> <select name="s2"> <option value="请选择" selected>请选择</option> </select> <script language="javascript"> //获取一级菜单长度 var select1_len = document.frm.s1.options.length; var select2 = new Array(select1_len); //把一级菜单都设为数组 for (i=0; i<select1_len; i++) { select2 = new Array(); } <?php $conn=new myconn(); $sql="select * from danwei where lishu = '$chang' order by quancheng"; $result=$conn->process($sql); $i=1; while($data=mysql_fetch_array($result)) { $sql="select id,quancheng from danwei where lishu='$data[1]'"; $result2=$conn->process($sql); ?> select2[<?php echo ($i);?>][0] = new Option("==请选择==", " "); <? $j=1; while($data2=mysql_fetch_array($result2)) { ?> select2[<?php echo ($i);?>][<?php echo $j;?>] = new Option("<?php echo $data2[1];?>", "<?php echo $data2[0];?>");//第一个option选1显示单位名,第二个option选0插入数据库的是单位id号 <?php $j++; } $i++; } ?> function redirec(x) { document.frm.s2.length=1; var temp = document.frm.s2; for (i=0;i<select2[x].length;i++) { temp.options=new Option(select2[x].text,select2[x].value); } if(select2[x].length==0)temp.options[0]=new Option("",""); //如果一级菜单为的子菜单项为空的时候,选择此一级菜单的时候,二级显示为空 temp.options[0].selected=true; } </script> <td align="center"><INPUT type=text name=diaoruri[] size="10" readonly></td> <? //注意:showCalendar(this)中的C一定得是大写?> <td align="center" rowspan="2"><INPUT type=button value=删除></td> </tr> <tr bgcolor="#FFFFFF"> <td align="center" class="style17" height="29">姓名</td> <td align="center"><input type="text" name=name[] size="10"></td> <td align="center" class="style17">技能(职称)等级</td> <td align="center"><input type="text" name=dengji[] size="8"></td> <td align="center" class="style17" width="10%">等级获得日期</td> <td align="center"><INPUT type=text name=dengjiri[] size="10" readonly></td> <? //注意:showCalendar(this)中的C一定得是大写?> <td align="center" class="style17" width="4%">岗位</td> <td align="center"><input type="text" name=gangwei[] size="10"></td> <td align="center" class="style17" width="10%">岗位取得日期</td> <td align="center"><INPUT type=text name=gangweiri[] size="10" readonly></td> <? //注意:showCalendar(this)中的C一定得是大写?> </tr> </TABLE> </td> </tr> </table> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="1"> <tr><td align="center"><input type="submit" value=保存结果 name=tijiao></td></tr> </table> </form> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="1"> <tr> <td class="style13"> <strong>填写说明:</strong><br>1、省份证号码、姓名、出生日期、参加工作日期、岗位、技能(职称)等级这6项是必填项,请保证全部填写。<br>2、调入本四级单位日期、等级获得日期、岗位取得日期这3项为选填,如不填写,系统将取当日时间。 </td> </tr> </table> </body> </html> |