[导入]Select的OnChange()事件
我们用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