laudy的博客

人变聪明容易,但想装糊涂可真难
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

[摘录]有什么办法,select改变时onchange能被触发

Posted on 2008-05-05 15:12  laudy  阅读(2685)  评论(0)    收藏  举报
<select   id=select1   onpropertychange="s_change()">  
  <option>1</option>  
  <option>2</option>  
  </select>  
  <input   type=button   value="test_obj"   name="test_obj"   onclick="test_select()">  
  <script>  
  function   test_select()  
  {  
   
  select1.options(1).selected=true;     //有什么办法,select改变时onchange能被触发  
  }  
  function   s_change()  
  {  
  if(event.propertyName=='selectedIndex')  
  {  
  alert('a');  
  }  
  else  
  {  
  alert(event.propertyName);  
  }  
  }  
  </script>



手动改变select的值,会触发onchange  
  脚本改变selectedIndex,不会触发onchange 解决办法
if   (select1.fireEvent)  
      select1.fireEvent("onchange")  
  else  
      select1.onchange()

<INPUT   type="button"   value="Button"   onclick="select1.selectedIndex=text1.value; select1.fireEvent('onchange')"> 我的程序,因为程序里有多个action里并每个action有多个submit按钮事件,为了区别代码,同时页面隐藏按钮
<select name="select" onchange="document.getElementById('seaoldsubmit').click();">
<option value="0">我的查询条件</option>
......
</select>
<input type="submit" name="seaoldsubmit" value="确定" style="display:none">
if(submitcheck('seaoldsubmit'))