由于文件域没有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;/" οnpaste=/"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" οnpaste="return false;" ></span></td>
</tr>
</table>
原文链接: http://blog.csdn.net/vince6799/article/details/520306