当前位置导航:炫浪网>>网络学院>>网页制作>>JavaScript教程

Javascript控制显示表单个数

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><LINK href="../hellking.css" type=text/css rel=stylesheet>
<body>
<%request.setCharacterEncoding("gb2312"); %>

<script type="text/javascript">
   function setid()
   {
   str='<br>';
   if(!window.form1.upcount.value)
    window.form1.upcount.value=1;
   if(window.form1.upcount.value>100){
   alert("您最多只能同时上传100个文件0");
   window.form1.upcount.value = 100;
   setid();
   }
   else{
    for(i=1;i<=window.form1.upcount.value;i++)
      str+='<div>文件'+i+':<input type="file" name="file'+i+'"></div><br><br>';
   window.upid.innerHTML=str+'<br>';}
   }
 </script>
<form name="form1" method="post" action="BookAction_do.jsp?action=${param.action}" >

  <div>
  <table border="1" cellspacing="0" cellpadding="5" bordercolordark="#CCCCCC" bordercolorlight="#000000" bordercolor="#FFFFFF" style="border-collapse: collapse" height="169">
    <tr bgcolor="#CC0CCC">
      <td height="28" align="left" valign="middle" bgcolor="#C0CCCC">&nbsp;
        <div><font size="3"><b>文件上传</b></font></div>
      </td>
    </tr>
    <tr align="left" valign="middle" bgcolor="#eeeeee">
      <td bgcolor="#eeeeee" height="92" valign="top"> <br>
        <table border="0" cellspacing="1" cellpadding="2">

          <tr>
            <td><font color="#FF0000"><b>*</b></font>上传的文件大小不能超过<font color="#FF0000">999999999</font>个字节</td>
          </tr>
          <tr>
            <td>

              <b><font color="#FF0000">*</font></b>每次可以设置同时上传<font color="#FF0000">100</font>个文件。<br>

              设置上传的个数
              <input type="text" value="1" name="upcount" size="20">
              <input type="button" name="Button"  onClick="setid();" value="设定">

            </td>
          </tr>

        </table>
      </td>
    </tr>
    <tr>
      <td id="upid">
        <div>文件1:
          <input type="file" name="file1">
        </div>
      </td>
    </tr>


  </table>
</div>
<br>
  <tr align="center" valign="middle" bgcolor="#eeeeee">
      <td bgcolor="#ccc000" height="33">
        <input type="submit" name="Submit" value="确定">
        <input type="reset" name="Submit2" value="重执">
      </td>
    </tr>
</table></form>
</body>
</html>

相关内容
赞助商链接