`
feiliboos
  • 浏览: 665345 次
文章分类
社区版块
存档分类
最新评论

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

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics