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

Please visit our partners


Windows Technology Windows Technology
15 Seconds
4GuysFromRolla.com
ASP 101
ASP Wire
VB Forums
VB Wire
WinDrivers.com
internet.commerce internet.commerce
Partners & Affiliates














ASP 101 is an
internet.com site
ASP 101 is an internet.com site
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
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 -->
<p>
How many numbers would you like to enter?
</p>
<!-- 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
	Next
	%>	
</select>
<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
	%>
	<p>
	You indicated you wanted to enter <%= Fields %> numbers.  Enter them below:
	</p>
	<%
	' 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 />
		<%
	Next
	%>
	<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.
	%>
	<p>
	You entered <%= Request.Form("number").Count %> numbers.
	</p>
	<p>
	They were:
	</p>
	<p>
	<%
	For I = 1 To Request.Form("number").Count
		Response.Write "<strong>Number " & I & ":</strong> "
		Response.Write Request.Form("number")(I)
		Response.Write "<br />" & vbCrLf
	Next
	%>
	</p>
	<%
End If
%>
</form>

Back the the Sample Output

Back to the Sample Index


Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

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