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

innerHTML中的控件不能附值
我的代码  
upfile.innerHTML= " <INPUT   style=\ "FONT-SIZE:   12px;   HEIGHT:   21px\ "   type=file   onchange=hid_value()   size=50   name=Upfile1> ";  
我用了document.all.Upfile1.value= "test ";什么也没有变化,不知道是怎么回事,大家帮帮忙!


------解决方案--------------------
file框是不能动态写值的
------解决方案--------------------
file只能读,不能写
------解决方案--------------------
下载个化境无组件上传包,里面的演示文件中就有
------解决方案--------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> 无标题文档 </title>
</head>
<script language= "javascript ">
function addfujian(){
window.document.getElementById( "span1 ").innerHTML+= ' <br> <input type= "file " name= "file " /> '
}

</script>
<body> <input name= " " type= "button " value= "增加附件 " onclick= "addfujian() "/>
<span id= "span1 ">
文件
<input type= "file " name= "file " />
</span>
</body>
</html>

==========================
至于怎么处理浏览到文件名,逆可以用循环的方法取得
for (var i=0;i <window.all( 'file ').length;i++){

}
------解决方案--------------------
动态生成的控件不能用document.all取得~~~

用document.getElementByName
------解决方案--------------------
file框里是不能写值的,这个是IE本身的设定,为了防止别人盗取你的文件
------解决方案--------------------
这么最是非法的