日期:2014-05-16 浏览次数:20381 次
<script language="javaScript"> function officecode() { //获取officename/officecode的值 var officename = document.form4.officename.value; var officecode = document.form4.officecode.value; //条件判断 if (officename == "语文办公室"){ document.form4.officecode.value=="0001"; } else if(officename == "数学办公室" ){ document.form4.officecode.value=="0002"; } else{ return false; } } </script>
<form name="form4" id="form4" action="new.php" method="post"> <table width="200" border="1"> <tr> <td width="80px;">办公室号码</td> <td><input type="text" name="officecode" style="width:100px;" /></td> </tr> <tr> <td width="100px;">办公室名称</td> <td> <select name="officename" id="officename"> <option value="语文办公室" selected>语文办公室</option> <option value="数学办公室">数学办公室</option> </select> </td> </tr> </table> <input type="button" value="确定" onclick="return officecode();"> 其他PHP内容,省略
<!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=utf-8" /> <title>无标题文档</title> <script type="text/javascript" src="js/jquery-1.7.1.min.js"></script> </head> <script language="javascript" type="text/javascript"> $(document).ready(function(){ $("ck").click(function(){ //点击按钮事件 if($("#name").value=="libin"){ $("#ct").val("001"); }; else if($("#name").value=="lisi"){ $("#ct").val("002"); }; }); $("#txt").val("2"); //试验用,证明jquery插入正确 }); </script> <body> <!--<div id="ct" style="z-index:1000">显示hidden值</div> <input type="text" name="issueType" value="55555555" id="issueType"/>--> <select name="name" id="name" /> <option value="libin">libin</option> <option value="lisi">lisi</option> </select> <input type="text" id="ct" name="ct" /> <input type="text" id="txt" name="txt" /> <input type="button" id="ck" name="ck" value="确认" /> </body> </html>
<table width=&q