ASP Getting Started tutorials-working with input form controls

Source: Internet
Author: User
Tags reset

To allow users to enter data through a form, you can create various form controls by using the input tag, and you can create different types of input form controls by setting the Type property of the input tag to a different value.

1, a single-line text box, the format is as follows:

i) Format:

  <form name="表单的名称" method="get | post" action="URL">

  <input type="text" name="字符串" value="字符串" size="整数" maxlength="整数">
  </form>

II) Properties:

A single-line text box has the following properties (Table i)

Property Meaning
NAME

Specifies the name of the text box through which you can reference the text box.

VALUE Specifies the initial value of a single-line text box.
SIZE Specifies the width of a single-line text box.
MAXLENGTH Specifies the maximum number of characters that are allowed to be entered in a text box.

III The code for the instance:

Instance 1 (1.asp)

<body>
<form method= "Post" Name= "Form1" action= "1.asp" >
<table align= "center" bgcolor= "#d6d3ce" width= ">"
<tr bgcolor= "#0099cc" >
<th colspan= "2" align= "Center" >
<font color= "#fffff" > Login Forms </font></th>
</tr>
<tr>
&LT;TD align= "Right" width= "height=" > Username:</td>
&LT;TD width= "height=" ><input type= "text" name= "name" size= "M" ></td>
</tr>
<tr>
&LT;TD colspan= "2" align= "center" ><input type= "reset" name= "Reset1" value= "Reset Data" >&nbsp;&nbsp;< Input type= "Submit" Name= "Submit1" value= "Submitting Data" >
</tr>
</table>
</form>
<%
Dim t1,a,b
T1=request.form ("name")
If t1<> "" Then
A= "<center><b> Your name is:"
b= "</b></center>"
Response.Write A & T1 & B
Else
Response.Write "<center><b> you have not entered your name </b></center>"
End If
%>
</body>

2, use the password control in the form. The format is as follows:

i) Format:

  <form name="表单的名称" method="get | post" action="URL">
  <input type="password" name="字符串" value="字符串" size="整数" maxlength="整数">
  </form>

The attribute has the name, VALUE, SIZE, and MAXLENGTH four items, and its meaning is shown in table I.

II) Instance code:

Instance 2 (2.asp)

<body>
<form method= "Post" Name= "Form1" action= "2.asp" >
<table align= "center" bgcolor= "#d6d3ce" width= ">"
<tr bgcolor= "#0099cc" >
<th colspan= "2" align= "Center" >
<font color= "#fffff" > Login Forms </font></th>
</tr>
<tr>
&LT;TD align= "center" width= "height=" > User name: <input type= "text" name= "name" size= "a" ></td>
&LT;TD align= "center" width= "height=" > Password: <input type= "password" name= "password" size= "" ></td>
</tr>
<tr>
&LT;TD colspan= "2" align= "center" ><input type= "reset" name= "Rest1" value= "Reset Data" >&nbsp;&nbsp;< Input type= "Submit" Name= "Submit1" value= "Submitting Data" >
</tr>
</table>
</form>
<%
Dim t1,ps,a,b,c
T1=request.form ("name")
Ps=request.form ("password")
If t1<> "" and ps<> "" Then
A= "<center><b> Your name is:"
b= "</b></center>"
c= "<center><b> Your password is:"
Response.Write A & T1 & B & "<br>"
Response.Write C & PS & B
Else
Response.Write "<center><b> you have not entered your name and password. </b></center> "
End If
%>
</body>

3, add the button control in the form, the format is as follows:

i) Format:

  <form name="表单的名称" method="get | post" action="URL">
  <input type="submit|reset|button" name="字符串" value="字符串" onClick="过程名">
  </form>

II) Properties

The button control has the following properties (Table II)

Property Meaning
NAME

Specifies the name of the button control.

VALUE Specifies the initial value of a Single-line button control.
TYPE

Specifies the type of the button control, which has the following three kinds of values.

1, submit: Create a Submit button. When you add a Submit button to a form, a site visitor can submit it after the form has been filled out. When a form is submitted, the form data (including the name and value of the submit button) is sent in ASCII text to the form handler specified by the form's Action property. In general, there must be a submit button in the form.

2, Reset: Create a reset button. When you add an override button to a form, site visitors can reset the form back to their default values. When you click the button, any text that has been entered into the field is deleted and any selections are cleared. However, if the box contains default text or if the option is default, clicking the reset button restores these settings values.

3, Button: Create a custom button. When you add a custom button to a form, you must write a script for the button to give it an action.

III) Events:

The button control also supports the OnClick event.

IV) Instance code:

Instance 3 (3.asp)

  <HTML>
  <HEAD><TITLE>在表单中使用按钮控件</TITLE>
  <SCRIPT LANGUAGE="VBSCRIPT">
  SUB MYSUB()
  AB="这是按钮的单击事件"
  MSGBOX AB
  END SUB
  SUB MYSUB1()
  Window.location.href=http://bianceng.cn
  end sub
  </SCRIPT>
  </HEAD>
  <BODY>
  <center><H3>调用事件过程</H3><HR WIDTH="70%" color="#009999">
  <INPUT TYPE="BUTTON" NAME="BUTTON" VALUE="事件" ONCLICK="MYSUB">
  <INPUT TYPE="BUTTON" NAME="BUTTON1" VALUE="网易" ONCLICK="MYSUB1">
  </center>
  </BODY>
  </HTMl>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.