<form id="search" name="search" target="_blank" method="get" action="http://news.baidu.com/ns">
输入关键字:
<input type="text" name="word" id="word"  onchange="kw.value=this.value" maxlength="100" />//这里为什么不对?
<input type="hidden" id="tn"  name="tn"  value="news"/>
<input type="hidden" id="ct" name="ct" value="0" /> 
<input type="hidden" id="kw" name="kw" value="" />
<input type="submit" value="进行搜索" />
</form>

解决方案 »

  1.   

    <form id="search" name="search" target="_blank" method="get" action="http://news.baidu.com/ns"> 
    输入关键字: 
    <input type="text" name="word" id="word" oninput="this.form.kw.value=this.value"  onpropertychange="this.form.kw.value=this.value" maxlength="100" />
    <input type="hidden" id="tn"  name="tn"  value="news"/> 
    <input type="hidden" id="ct" name="ct" value="0" /> 
    <input type="hidden" id="kw" name="kw" value="" /> 
    <input type="submit" value="进行搜索" /> <a href='#' onclick="alert(document.getElementById('kw').value)">KW的值</a>
    </form>
      

  2.   

    用 onkeydown 事件,在js里面取s的值,并设置p的值就行了。
    在 onkeydown 处理程序里面可以判断 按键是不是enter。只对enter响应。
      

  3.   

    onchange必须满足内容改变,并且该控件失去焦点才触发
    可以使用
    onpropertychange只需满足属性改变(包括内容改变)就可以触发(该属性只支持IE)
    oninput(该属性支持FireFox)等于onpropertychange
      

  4.   

    为什么不用 onkeypress="document.getElementById('ct')=this.value"
      

  5.   

    <input type="text" name="s" id="s" onpropertychange="aa()"/>
    <script language="JavaScript">
    function   aa(){
    document.getElementById("p").value   =  document.getElementById("s").value   
    }
    </script>
      

  6.   

    用 onkeydown 事件,在js里面取s的值,并设置p的值就行了。