日期:2014-05-16  浏览次数:20438 次

用js清除文件域的值 收藏

用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>

?

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/vince6799/archive/2005/11/01/520306.aspx

?

个人签名

-------------------------------------

?

图盾 淘宝保护 保护图片 图片防盗