js 文本框联动

来源:互联网 发布:物业管理app开发源码 编辑:程序博客网 时间:2024/05/01 19:25

2007/3/13   星期二

 

<!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>

 


<script>
function   change(e){
e.tx1.value=e.sel.options[e.sel.selectedIndex].value;
}

</script>

<script>

function   cli(e){
alert(document.fo1.sel.options[document.fo1.sel.selectedIndex].value);
alert("不提交页面");
}
</script>
</head>
<body>
<form name="fo1">
<label>城市名</label>
<select name="sel"  onchange="change(document.fo1)">
<option  selected="selected">请选择</option>
  <option value="苏州">苏州</option>
  <option  value="南京">南京</option>
</select>
<label> 城市信息:</label>
<input type="text" name="tx1" value="" onchange="change(document.fo1)"/>
<input type="submit" value="提交" onclick="cli(document.fo1.tx1)"/>
</form>
</body>
</html>