为什么呀?如果我还要动态写值怎么办?
是这样的,我做了个添加file控件的按钮,但是如果添加的过程中浏览了文件,再添加的话浏览的内容就没有了,我想先把这个值存起来,再附值,可是不能实现,怎么办?

解决方案 »

  1.   

    <!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++){}
      

  2.   

    动态生成的控件不能用document.all取得~~~用document.getElementByName
      

  3.   

    这个问题我已经用另外一种变通的方式解决了,谢谢各位!
    我的方法是一种笨方法,就是提前生成很多的<div id="test1"></div>每个input对应一个div,问题解决,谢谢大家!
      

  4.   

    file框里是不能写值的,这个是IE本身的设定,为了防止别人盗取你的文件
      

  5.   

    怎么会呢,我没有动态的向file里面写东西,只不过用一种变通的方式,没让file里面的内容消失