posts - 325,  comments - 25,  trackbacks - 0

var fn = 0;
 function addFile()
 {
  fn=fn+1;
  if(fn>4){
   fn = 4;
  }
  if(fn<=4){
   doFile(fn);
  }
 }
 function delFile()
 {
  fn=fn-1;
  if(fn<0){
   fn = 0;
  }
  if(fn>=0){
   (fn);
  }
 }

 function doFile(fileNum){
   var file01 = document.getElementById("file1");
   var file02 = document.getElementById("file2");
   var file03 = document.getElementById("file3");
   var file04 = document.getElementById("file4");
   if(fileNum==0){
    file01.style.display="none";
    file02.style.display="none";
    file03.style.display="none";
    file04.style.display="none";
    Upload.clear('fileAddr1');
    Upload.clear('fileAddr2');
    Upload.clear('fileAddr3');
    Upload.clear('fileAddr4');
   }
   if(fileNum==1){
    file01.style.display="";
    file02.style.display="none";
    file03.style.display="none";
    file04.style.display="none";
    Upload.clear('fileAddr2');
    Upload.clear('fileAddr3');
    Upload.clear('fileAddr4');
   }
   if(fileNum==2){
    file01.style.display="";
    file02.style.display="";
    file03.style.display="none";
    file04.style.display="none";
    Upload.clear('fileAddr3');
    Upload.clear('fileAddr4');
   }
   if(fileNum==3){
    file01.style.display="";
    file02.style.display="";
    file03.style.display="";
    file04.style.display="none";
    Upload.clear('fileAddr4');
   }
   if(fileNum==4){
    file01.style.display="";
    file02.style.display="";
    file03.style.display="";
    file04.style.display="";
   }
  }



<table border="0" cellspacing="0" cellpadding="0">
                                            <tr>
                                             
                                              <td width="2"></td>
                                              <td><a href="javascript:addFile();"><img src="../../image/sub_img/file/bt_plus.gif" border="0"></a></td>
                                            </tr>
                                          </table>
                                       </td>
                                        <td>
                                         <html:file property="fileAddr" name="webQnaForm" styleClass="input_01" style="width:100%;"></html:file>
                                        </td>
                                        <td align="center">
                                        <a href="javascript:delFile();">
                                        <img src="../../image/sub_img/file/bt_minus.gif" border="0">
                                        </a>
                                        </td>
                                      </tr>
           <tr id="file1" style="display:none">
            <td align="center">&nbsp;</td>
                                        <td>
                                         <html:file property="fileAddr1" name="webQnaForm" styleClass="input_01" style="width:100%;"></html:file>
                                        </td>
                                        <td align="center">&nbsp;</td>
                                      </tr>
           <tr id="file2" style="display:none">
            <td align="center">&nbsp;</td>
                                        <td>
                                         <html:file property="fileAddr2" name="webQnaForm" styleClass="input_01" style="width:100%;"></html:file>
                                        </td>
                                        <td align="center">&nbsp;</td>
                                      </tr>
           <tr id="file3" style="display:none">
            <td align="center">&nbsp;</td>
                                        <td>
                                         <html:file property="fileAddr3" name="webQnaForm" styleClass="input_01" style="width:100%;"></html:file>
                                        </td>
                                        <td align="center">&nbsp;</td>
                                      </tr>
           <tr id="file4" style="display:none">
            <td align="center">&nbsp;</td>
                                        <td>
                                         <html:file property="fileAddr4" name="webQnaForm" styleClass="input_01" style="width:100%;"></html:file>
                                        </td>
                                        <td align="center">&nbsp;</td>
                                      </tr>
                                      <tr>
            <td align="center">&nbsp;</td>
                                        <td height="19">
                                         <img src="../../image/sub_img/file/text.gif">
                                        </td>
                                        <td align="center">&nbsp;</td>
                                      </tr>
                                    </table>


<script type="text/javascript">
<!--
var Upload = {
clear: function(id){
var up = (typeof id=="string")?document.getElementById(id):id;
if (typeof up != "object") return null;
var tt = document.createElement("span");
tt.id = "__tt__";
up.parentNode.insertBefore(tt,up);
var tf = document.createElement("form");
tf.appendChild(up);
document.getElementsByTagName("body")[0].appendChild(tf);
tf.reset();
tt.parentNode.insertBefore(up,tt);
tt.parentNode.removeChild(tt);
tt = null;
tf.parentNode.removeChild(tf);
},
clearForm: function(){
var inputs,frm;
if (arguments.length == 0)
{
inputs = document.getElementsByTagName("input");
}else{
frm = (typeof arguments[0] == "string")?document.getElementById(arguments[0]):arguments[0];
if (typeof frm != "object") return null;
inputs = frm.getElementsByTagName("input");
}
var fs=[];
for ( var i=0; i<inputs.length; i++ )
{
if (inputs[i].type == "file") fs[fs.length] = inputs[i];
}
var tf = document.createElement("form");
for ( var i=0; i<fs.length; i++ )
{
var tt = document.createElement("span");
tt.id = "__tt__" + i;
fs[i].parentNode.insertBefore(tt, fs[i]);
tf.appendChild(fs[i]);
}
document.getElementsByTagName("body")[0].appendChild(tf);
tf.reset();
for ( var i=0; i<fs.length; i++)
{
var tt = document.getElementById("__tt__" + i);
tt.parentNode.insertBefore(fs[i],tt);
tt.parentNode.removeChild(tt);
}
tf.parentNode.removeChild(tf);
}
}
-->
</script>
posted on 2008-12-22 17:48 长春语林科技 阅读(422) 评论(0)  编辑  收藏 所属分类: js

只有注册用户登录后才能发表评论。


网站导航:
 
<2008年12月>
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

 

长春语林科技欢迎您!

常用链接

留言簿(6)

随笔分类

随笔档案

文章分类

文章档案

相册

收藏夹

搜索

  •  

最新评论

阅读排行榜

评论排行榜