日期:2014-05-17 浏览次数:20525 次
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<head>
<script language="javaScript">
function setofficecode()
{
//获取officename/officecode的值
var officename = document.getElementById("officename").value;
var o = document.getElementById("officecode");
//条件判断
if(officename == "XX办公室"){
o.value="101";
}
else if(officename == "YY办公室"){
o.value="201";
}
else if(officename == "ZZ办公室"){
o.value="301";
}
}
</script>
</head>
<form action="study3.php" method="post">
<div align="center">
<table>
<tr>
<td>办公室名称</td>
<td>
<select name="officename" id="officename" onchange="setofficecode()" style="width:150px;">
<?php
include('conn.php');
$sql="select * from officename";
$query=mysql_query($sql);
while($result=mysql_fetch_array($query)){
?>
<option value="<?=$result[officename]?>"><?=$result[officename]?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td>办公室号码</td>
<td><input type="text" name="officecode" id="officecode" style="width:150px;" value="101" /></td>
</tr>
</table>
<input type="submit" value="提交" />
</div>
</form>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<head>
</head>
<form action="study3.php" method="post">
<div align="center">
<table>
<tr>
<td>办公室名称</td>
<td>
<select name="officename" id="officename" onchange="document.getElementById('officecode').value=this.value" style="width:150px;">
<?php
include('conn.php');
$sql="select * from officename";
$query=mysql_query($sql);
while($result=mysql_fetch_array($query)){
?>
<option value="<?=$result['cod']?>"><?=$result['officename']?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td>办公室号码</td>
<td><input type="text" name="officecode" id="officecode" style="width:150px;" value="101" /></td>
<