Search DaTutorials:  
HOME
ASP Tutorials
Introduction
Reference
   Building ASP Pages
   Built-in Objects
Tutorials

A simple form parsing

Description:


How to process a form using ASP.

Code:

html> <body> <form action="parseform.asp" method="post"> Name: <input type="text" name="name" size="20"><br /> Sex: <select name="sex"> <option value="male">Male <option value="female">Feale </select><br /> Age: <input type="radio" name="age" value="below18">Below 18</input> <input type="radio" name="age" value="18plus">18+</input><br /> Interests: <input type="checkbox" name="interest_sport">Sports</input> <input type="checkbox" name="interest_music">Music</input> <input type="checkbox" name="interest_computers">Computers</input><br /> <input type="submit" value="Submit"> </form> <%
Dim name, sex, age, interest_sport, interest_music, interest_computers
name=Request.Form("name")
sex=Request.Form("sex")
age=Request.Form("age")
interest_sport = Request.Form("interest_sport")
interest_music = Request.Form("interest_music")
interest_computers = Request.Form("interest_computers")


If name<>"" Then
  Response.Write("<br />Your name is " & name & ".")
End If

If sex<>"" Then
  Response.Write("<br />You are a " & sex & ".")
End If

If age<>"" Then
  If age = "below18" Then
      Response.Write("<br />Your age is below 18 years.")
  Else		
      Response.Write("<br />Your age is above 18 years.")
  End If		
End If

If interest_sport = "on" Then
  Response.Write("<br />You are interested in sports.")
End If

If interest_music = "on" Then
  Response.Write("<br />You are interested in music.")
End If

If interest_computers = "on" Then
  Response.Write("<br />You are interested in computers.")
End If
%> </body> </html>

Test working example:


Keywords:

ASP: Request.QueryString, Response.Write

HTML: Form, Input

VBScript: Dim, If..Then


     eBay | Loans | Life Insurance | Loans | Remortgages
Home     Link To Us     Ad With Us     Contact Us     Tell A Friend     Affiliates     Blog     MsOfficeHelp