动态添加表单元素

来源:互联网 发布:自建 邮箱服务器 域名 编辑:程序博客网 时间:2024/04/30 23:34

源代码(1)

      <HTML>
<HEAD>
<STYLE TYPE="text/css">
<!--
.p9{ font-size: 9pt; font-family: 宋体 }
td {font-size: 9pt}
.tx {height: 16px; width: 30px; border-color: black black #000000; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; font-size: 9pt; background-color: #eeeeee; color: #0000FF}
.tx2 {height: 16px;border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; font-size: 9pt; color: #0000FF; border-left-color:#000000; border-right-color:#000000; border-top-color:#000000; border-bottom-color:#000000}
.bt {border-left:1px solid #C0C0C0; border-top:1px solid #C0C0C0; font-size: 9pt; border-right-width: 1; border-bottom-width: 1; height: 16px; width: 80px; background-color: #EEEEEE; cursor: hand; border-right-style:solid; border-bottom-style:solid}
.tx1 { width: 400 ;height: 20px; font-size: 9pt; border: 1px solid; border-color: black black #000000; color: #0000FF}
-->
</STYLE>
<SCRIPT LANGUAGE="vbscript">
function addfile()
dim str
str="<table>"
if not IsNumeric (window.form1.filenum.value) then window.form1.filenum.value =1
for i=1 to window.form1.filenum.value
str=str&"<tr><td valign='middle'>文件"&i&":</td><td><input type='file' name='file"&i&"' class='tx1' value size='20'>  保存为<input type='text' name='file"&i&"' size='20' class='tx2'></td></tr>"
next
window.uptd.innerHTML =str&"</table>"
end function
</SCRIPT>
<TITLE>人海孤鸿上传类</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312"></HEAD>
<BODY BGCOLOR="#ffffff" CLASS="p9" onLoad="addfile()">
<FORM METHOD="post" NAME="form1" ACTION="savetofile.asp" ENCTYPE="multipart/form-data">
  <TABLE BORDER="0" ALIGN="center" CELLPADDING="0" CELLSPACING="0">
    <TR>
      <TD><DIV ALIGN="center"><FONT COLOR="#0000ff" SIZE="5">人海孤鸿上传示例(保存到文件)</FONT></DIV></TD>
    </TR>
    <TR>
      <TD><TABLE WIDTH="750" BORDER="1" ALIGN="center" CELLPADDING="0" CELLSPACING="0" BORDERCOLOR="#111111" STYLE="BORDER-COLLAPSE: collapse">
          <TR>
            <TD HEIGHT="27" COLSPAN="2">上传
              <INPUT NAME="filenum" CLASS="tx2" VALUE="1" SIZE="4">
              个文件  
              <INPUT TYPE="button" NAME="Button" CLASS="bt" onClick="addfile" VALUE="设 定">
            </TD>
          </TR>
          <TR>
            <TD> <DIV ID="uptd"> </DIV></TD>
          </TR>
          <TR>
            <TD HEIGHT="30" COLSPAN="2" ALIGN="middle">
              <INPUT TYPE="submit" NAME="Button" CLASS="bt" VALUE="上 传">
                
              <INPUT TYPE="reset" NAME="Button" CLASS="bt" VALUE="重 置">
            </TD>
          </TR>
        </TABLE></TD>
    </TR>
    <TR>
      <TD HEIGHT="50" ALIGN="middle">版权所有 2005-2008   <A HREF="mailto:37989154@qq.com">37989154@qq.com</A> 
      </TD>
    </TR>
  </TABLE>
</FORM>
</BODY>
</HTML>

 

 

源代码(2)

     <html>
<head>
<title></title>
<script language="vbscript">
function addfile()
dim str
str="<table>"
if not IsNumeric (window.form.filenum.value) then window.form.filenum.value =1
for i=1 to window.form.filenum.value
str=str&"<tr><td valign='middle'>文件"&i&":</td><td><input type='file' name='photourl"&i&"' class='tx1' value size='20'></td></tr>"
str=str&"<tr><td valign='middle'>说明"&i&":</td><td><textarea rows='10' name='photoinf"&i&"'cols='80'></textarea></td></tr>"        
next
window.uptd.innerHTML =str&"</table>"
end function
</script>
<meta http-equiv="Content-Type"  content="text/html; charset=gb2312">
<link rel="stylesheet" href="css/style.css" type="text/css">
</head>
<body leftmargin="0" topmargin="0"   >
  <br>
<br>
<br>
<table width="90%" border="0" align="center" bgcolor="#000000" height="152" cellspacing="1">
  <tr>
    <td height="34" align="center" bgcolor="#FFFFFF"><font color="#FFFF33"><b><font size="4" color="#000000">选择图片</font></b></font></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">
      <form name="form"  method="post" action="upfile.asp" enctype="multipart/form-data" >
        <input type="hidden" name="filepath" value="photo">  <!--图片上传的目录-->
        <input type="hidden"  name="act" value="upload">
        <table width="750" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#111111" style="BORDER-COLLAPSE: collapse">
          <tr>
            <td height="27" colspan="2">上传
                <input name="filenum" class="tx2" value="1" size="4">
      个文件  
      <input type="button" name="Button" class="bt" onclick="addfile" value="设 定">
            </td>
          </tr>
          <tr>
            <td><div id="uptd"> </div></td>
          </tr>
          <tr>
            <td height="30" colspan="2" align="middle"><input type="submit" name="Button" class="bt" value="上 传">
        
        <input type="reset" name="Button" class="bt" value="重 置">
            </td>
          </tr>
        </table>
      </form>
    </td>
  </tr>
</table>
</body>
</html>

 

原创粉丝点击