JavaScript Tutorial - from entry to the master (8)
Related Tags:
JavaScript scripting using information to achieve interactive Web pages
To achieve dynamic interaction, we must master the form object (Form) and the Object Framework (Frames) more complicated knowledge.
First, form the basis of knowledge objects can form designers can form in different elements and interaction with client users, and do not need in the first place before data input, we can change the dynamic of Web documents.
1, what is the form object form (Form): it constitutes the Basic elements of Web pages. Usually a form of a Web page or a few forms, the use of Forms [] array to achieve different forms visit.
<form Name=Form1>
<INPUT Type=text...>
<Input Type=text...>
<Inpup Byne=text...>
</ Form>
<form Name=Form2>
<INPUT Type=text...>
<Input Type=text...>
</ Form>
Forms [0] in a total of three basic elements, and Forms [1] only two elements.
The main targets of the functions of the form is that it can directly access the html document form, which packages related HTML code:
<Form
Name = "Table the name"
Target = "window to the specified information"
Action = "procedures to receive the corresponding url form"
Method Data transmission mode = (get / post)
Enctype = "form coding"
[Onsubmit = "JavaScript code"]>
</ Form>
2, the method of object form object form only one way - submit () method, the method main function is to bring about a form of information submitted. If the Mytest form, use the following format:
Document.mytest.submit ()
3, Form object's properties in the form of the object attributes include the following: elements name action target encoding method.
Elements addition, several other are reflected in the logo of the form in the corresponding attributes of the state, which is usually a single form logo and the number of form elements is often elements of the array, were:
Elements [0]. Mytable.elements [1]
4, visit the form of objects in the JavaScript object to the form of two methods can be achieved:
(1) Through the visit form in the Form object's properties must first be designated in the form of its name and logo after the adoption of the following visit can form such as: document.Mytable ().
(2) to access an array of form Apart from the use of a form to access the form, the form may also be used to access an array of objects form object. But needed attention to the fact that, because of the form object is the provision of the browser environment, and the browser environment provided by the array subscript is from 0 to n. It can be realized through the following format form object visit:
Document.forms [0]
Document.forms [1]
Document.forms [2] ...
5, a prerequisite for use in the form of JavaScript to the form used to the conditions that: in the pages must be used to create the form logo, and form part on the definition used before.
In JavaScript to visit these basic elements, corresponding to a specific form through an array subscript Element or elements of the form to achieve. Each element is the adoption of the main elements of the attributes or methods to use. The basic format quoted below:
FormName.elements []. MethadName (of the form. Element or array. Methods)
FormName.elemaent []. PropertyName (of the form. Element or array. Attributes)
Below were introduced:
1, Text input single separate functional elements: Text logo on the elements in the effective control.
Fundamental attributes:
Name: Setting the information submitted information name. Corresponds to the HTML document in the Name.
Value: set to appear in the window corresponding HTML documents Value information.
Defaultvalue include: Text the default value of the basic elements:
Blur (): the current focus will be moved to the background.
Select ():-plus text.
Main events:
OnFocus: When Text focus was generated during the incident.
OnBlur: Elements lose focus, have the incident.
Onselect: When the text was additionally-show, produced the document.
Onchange: When Text elements of change, produced the document.
Example: ...
<Form Name="test">
<input Type="text" name="test" value="this is a javascript">
</ Form>
...
<script Language ="Javascirpt">
Document.mytest.value = "that is a Javascript";
Document.mytest.select ();
Document.mytest.blur ();
</ Script>
2, textarea lines in the importation of more functional elements: the implementation of the elements Textarea control.
Fundamental attributes
Name: Setting the information submitted information name, the corresponding HTML documents Textarea Name.
Value: set to appear in the window corresponding HTML documents Value information.
Default value: Elements of the default values.
Methods:
Blur (): input focus will be lost
Select (): [after the incident highlights:
OnBlur: When losing focus after the input of the incident
OnFocus: When the focus was imported, produced the document
Onchange: When [value changes, the incident generated
Onselect: When text-plus, the document produced 3, choose Select functional elements: the implementation of the rolling elements of the control options.
Attribute:
Name: Setting the information submitted information name, select the corresponding file name.
Length: select the corresponding documents length
Options: an array composed of a number of options
SelectIndex; the standard specified under an option
Select the options contained in each of the following attributes:
Text: Option corresponding text
Selected: specify whether the options selected
Index: specify the location of the current options
Defaultselected: The default option incident:
OnBlur: When select Options lose focus, produced the document.
OnFocas: When was the focus select, produce the document.
Onchange: After the change of status options, have the incident.
4, Button button function: the implementation of Button button control.
Attribute:
Name: Setting the information submitted information name, the corresponding documents in the Name button.
Value: set to appear in the window corresponding HTML documents Value information.
Methods:
Click () method similar to the press of a button.
Events:
Onclick When you click button button, have the incident.
Example:
<Form Name="test">
<input Type="button" name="testcall" onclick=tmyest()>
</ Form>
...
<script Language="javascirpt">
Document.elements [0]. Value = "mytest" / / visit or by elemental
Document.testcallvalue = "mytest" / / by name visit
</ Script>
.....
5, checkbox check box features: the implementation of a control element in the box.
Attribute:
Name: Setting the information submitted information name.
Value: set to appear in the window corresponding HTML documents Value information.
Checked: the attribute specified frames true state / false.
Defauitchecked: default:
Click () method makes a frame of a selected item.
Events:
Onclick: When the election box was checked, have the incident.
6, wireless radio button function: the implementation of a wireless function of a radio button control.
Attribute:
Name: Setting the information submitted information name, the corresponding radio HTML documents in the name of the same
Value: to appear in the window settings corresponding HTML documents Value information, in the corresponding HTML document the radio name.
Length: radio button in the number of buttons.
Defalechecked: The default button.
Checked: specified selected or not selected.
Index: Check the location of the button.
Methods:
Chick (): select a button.
Events:
Onclick: Click the button, have the incident.
7, hidden: hidden function: the implementation of a non-display text characters and can enter the regional elements of control.
Attribute:
Name: Setting the information submitted information name, the corresponding HTML documents hidden in the Name.
Value: set to appear in the window corresponding HTML documents Value information, corresponding HTML documents hidden in value.
Defaleitvalue: Default 8, Password password function: the implementation of a password input elements of control.
Attribute:
Name: Setting the information submitted information name, password in the corresponding HTML documents in the name.
Value: set to appear in the window corresponding HTML documents Value information, in the corresponding HTML documents in the Value password.
Defaultvalu: The default value method
Select ():-importation of Canadian domain password.
Blur (): make it lost passward input focus.
Focus (): access password input focus.
9, submit to the functional elements: the implementation of a button control.
Attribute:
Name: Setting the information submitted information name, submit corresponding HTML documents.
Value: set to appear in the window corresponding HTML documents Value information, the corresponding value in the HTML document.
Methods
Click () equivalent to press the submit button.
Events:
Onclick () when pressing the button, have the incident.
Third, we demonstrated by the following examples click of a button (red) to change the window colors, click on "button called dynamic document" button call a dynamic document.
Test8_1.htm
<html>
<head>
<Script Language="JavaScript">
/ / The original color
Document.bgColor = "blue";
Document.vlinkColor = "white";
Document.linkColor = "yellow";
Document.alinkcolor = "red";
/ / Dynamic change color
Function changecolor () (
Document.bgColor = "red";
Document.vlinkColor = "blue";
Document.linkColor = "green";
Document.alinkcolor = "blue";
)
</ Script>
</ HEAD>
<body BgColor="White">
<A Href="test8_2.htm"> Calling Dynamic Document button </ a>
<form>
<Input Type="button" Value="red" onClick="changecolor()">
</ Form>
</ BODY>
</ HTML>
Figure 1 shows the output results.

Figure 1
Dynamic button procedures.
Test8_2.htm
<HTML>
<HEAD>
</ HEAD>
<p Align="center"> </ p>
<div Align="center"> <center>
<table Border="0" cellspacing="0" cellpadding="0">
<tr>
<td Width="100%"> <form name="form2" onSubmit="null">
<p> <Input type = "submit" name = "banner" VALUE = "Submit"
OnClick = "alert ( 'You have to put an \' action = [url] \ 'on the form
Tag !!')"> <br>
<script Language="JavaScript">
Var id, pause = 0, Position = 0;
Function banner () (
/ / Variables declaration
Var i, k, msg = "Here you have to input the content of" / / increase msg
K = (30/msg.length) 1;
For (i = 0; i <= k; i) msg = "" msg;
/ / Show it to the window
Document.form2.banner.value = msg.substring (position, position-30);
/ / Set new position
If (position == msg.length) position = 0;
/ / Repeat at entered speed
id = setTimeout ( "banner ()", 60);)
/ / End ->
Banner ();
</ Script> </ p>
</ Form>
</ Td>
</ Tr>
</ Table>
</ Center> </ div>
<p> </ P>
<BODY>
<A Href="test8_1.htm"> return </ a>
</ BODY>
</ HTML>
Figure 2 shows the output results.

Figure 2
The stresses on the use of JavaScript scripting information to Web pages interactive approach. Mainly on the basic elements of the form in the main function and use.
- Fast proficient in the use of master FRAME
- W3C school HTML help guide CHM
- W3c validator: CSS/HTML4.01/XHTML1.0 XiaoZhu.com have passed smoothly:)
- WEB master HTML chapter of the courses
- Web master - page scroll Break
- Google entry to the master
- Ajax master series
- Fast proficient in the use of master framework
- Destination establishment - from entry to the master - for articles
- W3c technical architecture introduced
- GMail view from the W3C Web standards and Ajax
- Destination establishment - from entry to the master - basic knowledge
- Part V reference master Ajax
- W3C XHTML code norms
- CSS learning from entry to the master
- Destination establishment - from entry to the master - chapter details
- Destination establishment - from entry to the master (thematic)
- Web standards: XHTML + CSS (W3C)
- XHTML + CSS + JavaScript Learning Resources (major sites, W3C School)
- Blog.csdn.net support of the W3C CSS problems




