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

解决方案 »

  1.   

    你这里names 取的是下面的input,你input里填值就取得到了.
      

  2.   

    写成<input type="text" id="names"  /> 
      

  3.   

    你是想要取得选择内容?
    <!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>
      

  4.   

    <input type="text" name="names" id="names" />
    加上id属性