用js清除文件域的值(原创) 收藏
由于文件域没有value属性,所以就无法用清除value的方法来清除文件域的值,这个是一个替代的方法在需要清除时用js重写文件域。在需要清除时用js重写文件域。(有更好的方法希望能与我联系:vince6799@hotmail.com或访问www.miplat.com)
<table>
<tr>
<script language="javascript">
function clear()
{
document.getElementById("pfile").innerHTML = "<input type=\"file\" name=\"file\" onKeyDown=\"return false;\" onpaste=\"return false;\"/>";
}
function showpic(them){
if (them.value=="2")
{document.all.pic.style.display='';
}
else
{document.all.pic.style.display='none';
clear();
}
}
</script>
<td> 类别:
<select name="news_type" onChange="showpic(this)">
<option value="1">工作动态</option>
<option value="2">图片新闻</option>
<option value="3">通知通告</option>
</select></td>
</tr>
<tr id="pic" style="display:none;">
<td height="11" valign="top">标题图片:
<span id="pfile"><input type="file" name="file" onKeyDown="return false" onpaste="return false;" ></span></td>
</tr>
</table>
本文来自优快云博客,转载请标明出处:http://blog.youkuaiyun.com/vince6799/archive/2005/11/01/520306.aspx
个人签名
-------------------------------------