<!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 ff(){
aa=document.getElementById("names").value;
alert(aa);
}
</script>
</head><body><form action="b.php" method="post"><select name="sl" onchange="ff()">
<option value="1">aa</option>
<option value="2">bb</option>
<option value="3">cc</option>
<option value="4">dd</option>
</select>
<input type="text" name="names" />
<input type="submit" value="提交" />
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script>function ff(){
aa=document.getElementById("names").value;
alert(aa);
}
</script>
</head><body><form action="b.php" method="post"><select name="sl" onchange="ff()">
<option value="1">aa</option>
<option value="2">bb</option>
<option value="3">cc</option>
<option value="4">dd</option>
</select>
<input type="text" name="names" />
<input type="submit" value="提交" />
</form>
</body>
</html>
<!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 ff(){
var aa=document.getElementById("sl").selectedIndex;
var seltxt=document.getElementById("s1").options[aa].text;
document.getElementById("names").value=seltxt;
}</script>
</head><body><form action="b.php" method="post"><select name="sl" id="s1" onchange="ff()">
<option value="1">aa </option>
<option value="2">bb </option>
<option value="3">cc </option>
<option value="4">dd </option>
</select>
<input type="text" name="names" />
<input type="submit" value="提交" />
</form>
</body>
</html>
加上id属性