[匯入]Select的OnChange()事件

來源:互聯網
上載者:User

我們用Select的onchange事件時,常會遇到這樣一個問題,那就是連續選相同一項時,不觸發onchange事件.select的onchange事件就是這樣子的.你得有Change(改變),才能觸發該事件....

掌握了它的特性後,相應的解決辦法也很簡單.

<select onchange="txt.value+=this.options[this.options.selectedIndex].value;this.options[0].selected=true;">
<option value="">請選擇</option>
<option value="1">Item 1</option>
<option value="2">Item 2</option>
<option value="3">Item 3</option>
</select>
<textarea id="txt"></textarea>

<form><input id="FileUpload" type="file" style="width:448px; height: 22px;" onchange="FileUpload_onselect()" >
<input name="TbxName" id="TbxName">
<input name="Tbx_FileName" id="Tbx_FileName">
</form>
<script type="text/javascript" language="javascript">   
function FileUpload_onselect()
{
  var path;
  path = document.forms[0].FileUpload.value; //C:\Documents and Settings\hud\案頭\AddFile.jpg
  var aa;
  aa = path.split('.');
  document.all('TbxName').value = aa[aa.length - 1]; //jpg 結果
  var name;
  name = path.split('\\');
  var bb = name[name.length - 1];
  document.all('Tbx_FileName').value = bb.substr(0, bb.indexOf('.')); //AddFile 結果
}
</script>

文章來源:http://Jorkin.Reallydo.Com/default.asp?id=564

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.