可能你的写法不对吧,你试试我写的这个:
<input name="test" onchange="alert('This is a test!');">
<input type="button" value="test" onclick="document.all.test.onchange();">

解决方案 »

  1.   

    因为焦点没有到test控件上,所以没有触发onchange,但你可以换一个最灵敏的事件:<input name="test" onPropertyChange="change()">
    <input type="button" value="test" onclick="document.all('test').value='test'"><script>function change(){alert("ok")}</script>
      

  2.   

    onchange 事件是在控件失去焦点时触发的(即不是只要内容一改变就触发,一般是在用户离开或提交FORM时触发),在 onblur 事件之前
    你可以强制控件取得和失去焦点<input name="test" type=??? onchange="change()"> --- 没有指定type,到底是个什么input啊
    <input type="button" value="test" onclick="with(document.all.test){select();value='test';blur()}">
      

  3.   

    如果input控件只需要用程序设定text,不打算让用户手工输入的话,才可以采用梅花雨的解决方法
    如果打算同时让用户输入,只能用onchange事件
    onPropertyChange不能代替onchange
    onPropertyChange事件是用户每输入一个字符就激活一次,而onchange是最后提交时才触发