为了改变<INPUT type="file"> 控件中按钮的 风格,我采用如下做法,但是有问题,清高手指教画面上,我做三个控件  
1)  <INPUT type="file" id="file1">  
2)  <input type="button" onclick="document.all.file1.click()"
3)  <input type="submit">第二个控件做成我想要的风格,然后,覆盖到第一个控件的"browse" 按钮上
点击按钮button,确实达到了点击第一个控件按钮的效果,即弹出文件选择框,选择文件。但是问题是,这时候点击第三个控件submit的时候,第一个控件的内容被清空了,
根本不跳转服务端,然后,再一次电击第三个控件submit的时候,才跳转到服务端,
但这个时候,第一个控件的内容已经是空的了。在服务端得不到内容了。
使用第一个控件的"browse" 按钮,就没有这个问题注:第三个控件submit不可少,而且点击要跳转服务端不知这个问题如何解决,100分奉上

解决方案 »

  1.   

    <input type="button" onclick="document.all.file1.click()"
    这是不成的,如果不点击file1,无论采用什么其他的方式,微软是不会让你的信息提交成功的。
    所以这是不可以的,但是可以变通网络上流行的方法
    方法一:采用Frame
    <body>
    <iframe name=fileList></iframe>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    fileList.document.write("<form name=f action='http://www.csdn.net'>");
    fileList.document.write("<input type=file name=f0>");
    fileList.document.write("<input type=file name=f1>");
    fileList.document.write("<input type=file name=f2>");
    fileList.document.write("</form>");
    //-->
    </SCRIPT>
    <BR>
    <input name="file0">
    <input type="button" value="浏览..." onclick="fileList.document.f.f0.click();file0.value=fileList.document.f.f0.value"> 
    <BR>
    <input name="file1">
    <input type="button" value="浏览..." onclick="fileList.document.f.f1.click();file1.value=fileList.document.f.f1.value"> 
    <BR>
    <input name="file2">
    <input type="button" value="浏览..." onclick="fileList.document.f.f2.click();file2.value=fileList.document.f.f2.value"> 
    <BR>
    <input type=button onclick="fileList.document.f.submit();" value="提交">
    </body>
      

  2.   

    方法二:使用隐形的file,将隐形的file放在你的Button上边,透明度为100%
    这样你就可以点file乐,不过Button的样式就不好弄了——毕竟你没有点到
    Button的上边,所以最好用自定义的Div代替Button,通过Css控制Div的样式。
      

  3.   

    <div style="position:absolute;top:11px;left:-71px;width:150;filter:alpha(opacity=0)" >
      <input name="file" type="file" size=33 onpropertychange="a.value=this.value">
    </div> 方法一是:
    <script  language=javascript>  
    function  window.onload()  
    {  
           document.form1.T1.focus();  
           var  WshShell=new  ActiveXObject("WScript.Shell");  
           WshShell.sendKeys("c:\\test.txt");  //向文本框里发送东东  
    }  
    </script>