如何使用ASP制作模似动态生长的表单

FILE: DYNAFORM.ASP

1@ language = vbscript
1 Response.Expires = 0 
1<html>
2<head>
3<title>Dynamically Growing Form</title>
4</head>
5<body>   

If Request("Action") = "Submit the List" Then
' Show what was entered.
Response.Write "<b>Here are the Items submitted:</b><br/>"
nItems = Request.Form("Items").Count
For I = 1 To nItems
' Show submitted Items
Response.Write Request.Form("Items")(I) &amp; "<br/>"
Next
Response.Write Request("Item") &amp; "<br/>"

Else

' Create the form from all items.

1<form action="dynaform.asp" method="Post">
2<b>Items:</b><br/>   

nItems = Request.Form("Items").Count
For I = 1 To nItems
' Show previously submitted Items
Response.Write "<input "="" """="" &="" _="" name="Items" trim(request.form("items")(i))="" type="Text" value=""/><br/>"
Next

If Request.Form("Item") &lt;&gt; "" Then
' paint a new input box, and store the old Item in Items collection
Response.Write "<input "="" """="" &="" _="" name="Items" trim(request.form("item"))="" type="Text" value=""/><br/>"

Response.Write "<p>Please enter an Item,<br/>"
Response.Write "and submit them one at a time<br/>"
Response.Write "by pressing the Add Item button.<br/>"
Response.Write "<input """"="" name="Item" size="50" type="Text" value=""/>"
Else
' No Item was submitted, don't show an error
Response.Write "<p>Please enter an Item,<br/>"
Response.Write "and submit them one at a time<br/>"
Response.Write "by pressing the Add Item button.<br/>"
Response.Write "<input """"="" name="Item" size="40" type="Text" value=""/> <br/>"
End If

1  
2<p>
3<input name="Action" type="Submit" value="Add Item to List"/>
4<input name="Action" type="Submit" value="Submit the List"/>
5<br/>   
6  

End If

1  
2</p></p></p></form>
3</body>
4</html>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus