(Chapter VII) using a form

Chapter 7 Forms

table of Contents

Chapter 7 Forms

1, form tag form

1.1 submit form action

1.2 Form Name name

1.3 transfer method method

1.4 encoding

1.5 target object display method

2, is inserted into the form object

2.1 text field text

2.2 password domain password

2.3 radio button radio

2.4 checkbox checkbox

2.5 ordinary button button

2.6 submit button

2.7 Reset button reset

2.8 image domain

2.9 hidden fields hidden

2.10 Domain file file

3, menus and lists

3.1 drop-down menu

3.2 list items

4, the text field labeled textarea

5, id tag


Many forms of use in web pages, in particular, often use when creating dynamic web pages. The main forms used to collect information provided by the client, the website has interactive features. In the web production process, often you need to use the form, such as membership registration, online surveys and search. Visitors can use text fields, list boxes, check boxes and radio buttons form object such input information, and then click a button to submit the information.

1, form tag form

In page <form> </ form> tag is used to create a form, i.e., start and end positions define the form of, among all the markers are all forms of content. In <form> tag in the form, the form of the basic properties may be provided, including the name of the form, method and transmission handler. In general, the form action handler method and transmission method are essential parameters.

1.1 submit form action

action for submitting the form data to specify which address processing.

grammar:

<form action="表单的处理程序">
......
</form>

1.2 Form Name name

Necessary attribute name is used to form named, this property is not the form, but confusion occurs when the form is submitted to the spooler in order to prevent the general need to form a name.

grammar:

<form name="表单名称">
...
</form>

Form names can not contain special characters and spaces.

1.3 transfer method method

Form method attribute specifies when the data submitted to the server using HTTP which submission method, get the possible values ​​or post.

get: the form data is transmitted to the action attribute specified URL, and then the new URL is sent to the handler.

post: form data is contained in the form body, and is then sent to the processing program.

grammar:

<form method="传送方法">
......
</form>

1.4 encoding

Enctype attribute in a form for encoding the provided information submitted form.

grammar:

<form enctype="编码方式">
......
</form>

1.5 target object display method

targeting to target Open window, the target window forms are often used to return information display form.

grammar:

<form target="目标窗口的打开方式">
......
</form>

Open the target window has four options, _blank, _parent, _self and _top. _Blank wherein the linked file is loaded a new, unnamed browser window; _parent to load the linked file containing the link frame frameset parent or the parent window; _self to load the linked document that the same frame or window as the link; _top to load the entire browser window so that the linked file removing all frames.

2, is inserted into the form object

Web page forms by many different form elements. These form elements including text fields, radio buttons, check boxes, menus and lists, and buttons.

2.1 text field text

The page is the most common form element is the text field, the user can input characters or single-line text in a text field.

grammar:

<input name="控件名称" type="text" value="文字字段的默认值" size="控件的长度" maxlength="最长字符数" />

2.2 password domain password

A special password field is a text field, each of its attributes and text fields are the same. The difference is that all the characters in a password input field with an asterisk "*" indicates.

grammar:

<input name="控件名称" type="password" value="文字字段的默认取值" size="控件的长度" maxlength="最长字符数" />

2.3 radio button radio

Radio buttons are small, round button, which allows the user to select an option from the selection list.

grammar:

<input name="单选按钮名称" type="radio" value="单选按钮的取值" checked />

It must be set in the radio button for value, for all the radio buttons to select a list, it is often the same name to be set, so that when passing to a better selection of one judge. In a radio button group, only one radio button can be set to checked.

2.4 checkbox checkbox

Check box allows users to select multiple options from a list of options.

grammar:

<input name="复选框名称" type="checkbox" value="复选框的取值" checked />

2.5 ordinary button button

On a web page buttons are also very common in the submission page, it is often used to clear the contents. Under normal circumstances ordinary Button to tie scripts to perform form processing.

grammar:

<input type="button" name="按钮名称" value="按钮的取值" οnclick="处理程序" />

The value of value is displayed in text on the button in the button onclick attribute can be added to achieve some special features.

2.6 submit button

Submit button is a special button, click the button class can achieve a form of content submitted.

grammar:

<input type="submit" name="按钮名称" value="按钮的取值" />

2.7 Reset button reset

Reset button to clear the information entered by the user in the page.

grammar:

<input type="reset" name="按钮名称" value="按钮的取值" />

2.8 image domain

You can also use an image as a button, doing so can create any look imaginable buttons.

grammar:

<input name="图像域的名称" type="image" src="图像路径" />

2.9 hidden fields hidden

Sometimes may want to transfer some of the data, the data for the user is not visible. Such data may be transmitted through a hidden field. What is included in hidden fields to submit data processing, but these data do not show in the browser.

grammar:

<input name="隐藏域名称" type="hidden" value="隐藏域的取值" />

2.10 Domain file file

文件域在上传文件时常常用到,它用于查找硬盘中的文件路径,然后通过表单将选中的文件上传,在上传图像时也常常用到。

语法:

<input name="文件域名称" type="file" size="控件的长度" maxlength="最长字符数" />

3、菜单和列表

3.1下拉菜单

下拉菜单是一种最节省页面空间的选择方式,因为在正常状态下只显示一个选项,单击下拉按钮打开菜单后才会看到全部的选项。

语法:

<select name="下拉菜单名称">
<option value="选项值" selected>选项显示内容</option>
......
</select>

3.2列表项

在页面使用列表项可以显示出几条信息,一旦超出这个信息量,在列表项右侧会出现滚动条,拖动滚动条便可以看到所有选项。

语法:

<select name="列表项名称" size="显示的列表项数" multiple>
<option value="选项值" selected>选项显示内容</option>
......
</select>

4、文本域标记textarea

当需要让浏览者填入多行文本时,就应该使用文本域而不是文字字段。和其他大多数表单对象不一样,文本域使用的是textarea标记而不是input标记。

语法:

<textarea name="文本域名称" cols="列数" rows="行数"></textarea>

在语法中,不能使用value属性来建立一个在文本域中显示的初始值。相反,应当在textarea标记的开头和结尾之间包含想要在文本域内显示的文本。

5、id标记

id标记是一个较为特殊的标记,它主要用于标示一个惟一的元素。这个元素可以是文字字段,可以是密码域,也可以是其他的表单元素,甚至可以是一幅图像、一个表格。

语法:

<id = 元素标识名>

 

发布了17 篇原创文章 · 获赞 0 · 访问量 213

Guess you like

Origin blog.csdn.net/SUN19980421/article/details/104452456