ASP 101 - Active Server Pages 101 - Web05
The Place ASP Developers Go!

Please visit our partners

Windows Technology Windows Technology
15 Seconds
ASP 101
ASP Wire
VB Forums
VB Wire
internet.commerce internet.commerce
Partners & Affiliates

ASP 101 is an site
ASP 101 is an site
Internet News
Small Business
Personal Technology

Corporate Info
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash

ASP Source Code:
Dim I
Dim Fields
' Retrieve the number of fields we're dealing with.
Fields = CInt(Request.Form("fields"))
If Fields = 0 Then Fields = 1
<form action="<%= Request.ServerVariables("URL") %>" method="post">
<!-- This section is always shown -->
How many numbers would you like to enter?
<!-- There's no reason this has to be a select box.  You could just as
easily let the user type in a number, but I didn't want to deal with
the additional validation.  Your situation will probably determine if
the wider range of choices is worth the validation work.
<select name="fields">
	' Display number of fields selection box.
	For I = 1 to 20
		Response.Write "<option"
		If I = Fields Then Response.Write " selected=""selected"""
		Response.Write ">" & I & "</option>" & vbCrLf
<input type="submit" name="submit" value="Enter Numbers Now">
<!-- This section changes based on what pass through the script we're on. -->
' Figure out which pass through the script we're on by the value
' of the submit button.
If Request.Form("submit") = "Enter Numbers Now" Then
	You indicated you wanted to enter <%= Fields %> numbers.  Enter them below:
	' I'm prefilling the forms with some data for convenience to
	' illustrates that the values are actually sent... in a real
	' live situation you probably wouldn't enter a value.
	For I = 1 to Fields
		<strong>Number <%= I %>: </strong><input type="text" name="number" value="<%= I %>" /><br />
	<input type="submit" name="submit" value="Submit Numbers">
ElseIf Request.Form("submit") = "Submit Numbers" Then
	' Done... display entries.  In the real world you'd validate the
	' entries and then do whatever you're doing to process the results
	' here.  I'm just echoing them back out to the browser.
	You entered <%= Request.Form("number").Count %> numbers.
	They were:
	For I = 1 To Request.Form("number").Count
		Response.Write "<strong>Number " & I & ":</strong> "
		Response.Write Request.Form("number")(I)
		Response.Write "<br />" & vbCrLf
End If

Back the the Sample Output

Back to the Sample Index

Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback
The Network for Technology Professionals



Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers