In the development of web page, there is always a summary of some pages. This article summarizes some of the relevant applications of some JavaScript encountered in the development process. I hope to be more perfect in the future, check box problem
Function incheckall () /// Check confirmation checkbox to all or not
{
IF (other sub-check boxes)
Formname.checkboxname.checked = true;
Else
Formname.checkboxname.checked = false;}
Function INSELECTALL () /// The main return box is selected for a selection,
{
IF (other sub-check boxes)
{
Document.formname.Element [i] = false; /// use for cycle
}
Else
{
Document.formname.Element [i] = true; /// uses for loop
}
}
}
// ->
script>
Second, the history of history retreats one step:
JavaScript: history.back (); ---- In Input Type = "Button" οnclick = 'javascript: history.back ()'> can be used directly, no need to set up a JavaScript function
Third, the primary drop-down menu is selected, and the sub-drop menu is selected.
Tip: Directly put the address of the sub drop menu with the address of the primary drop-down menu.
example:
Function ChangeAll ()
{
Form.selectchild.selectedIndIndex = form.selectfather.selectedIndex; // successdIndex property gives the option in the option in the Options array
}
Fourth, a RADIO group and a button, selected a Radio and then triggering events to other pages
Code:
method one:
Function Radionotyet (Radioname, Total, Content) {
///iff radio group Has NOT been Motified Return -1, else return the success company
For (j = 0; j IF (radioname [j] .checked == true) returnj; } // for Alert ("Yes Yes" Content); Return -1; } // Function Radionot Function nextstep () /// uses the mutual call of the script function { Switch (radionotyet (Radio1, 2, where is next step? ")) { Case -1: return; Case 0: location = "Greenpassstep2.htm"; Break; Case 1: Location = "Greenpassstep3.htm"; Break } } Method Two: IF (! document.formname.radiogroup1 [0] .checked &&! Document.formname.radiogroup1 [1] .checked &&! document.formname.radioGroup1 [2] .checked Alert ("Please select the way you want to do!"); Else if (Document.FormName.RadioGroup1 [0] .checked) Location = "Memberpassstep3.html"; Else if (Document.FormName.RadioGroup1 [1] .checked) Location = "MEMBERPASSSTEP4.HTML"; Else if (Document.FormName.RadioGroup1 [2] .checked) Location = "MemberpassStep6.html"; } 5. Decades whether the content of the text box is empty and if you fill in the correct information Method 1 (directly for each write code): Function jump () { VAR PATRN2 = / ^ (/ w) {6, 20} $ /; // This is a regular expression, the judgment is 6 ~ 20 digits, the test password is used /// In fact, it can also be like this: if (Document.FormName.PasswordName.Value.Length <6 || Document.FormName.PasswordName.Value.Length> 20) Alert ('Enter the password length is not right); VAR PATRN3 = / ^ (/ w) {6, 20} $ /; IF (Document.FormName.textfieldName.Value == "") // is a single text box { Alert ("Please fill in the detailed delivery address!"); Document.formname.textfieldname.focus (); } ///. FOCUS represents the focus of positioning mouse Else if (Document.form.TextFieldName [0] .Value == "") / // is available for a series of text boxes, available arrays { Alert ("Please fill in the name of the order!"); Document.formname.textfieldname [i] .focus (); } /// i is the variable ...... VAR PATRN2 = / ^ [A-ZA-Z0-9] {3, 12} $ /; //////////> Use the regular expression to determine if the information input is correct VAR PATRN3 = / ^ [0-9] {1, 20} $ /; IF (! PATRN2.EXEC (Document.formame.textfieldName [4] .value) ||! PATRN3.EXEC (Document.formame.TextFieldName [4] .value)) Alert ("Please enter the correct postal package!"); Else Location = "Greenpasstep7.htm"; Else if (! PATRN2.EXEC (Document.formame.TextFieldName [6] .value)) Alert ("Please enter 6-20 letters, numbers, underscore!"); Else if (! PATRN3.EXEC (Document.formame.TextFieldName [7] .value)) Alert ("Please enter 6-20 letters, numbers, underscore!"); Else Location = "GreenpassStep7.htm"; } Method 2 (Use the mutual call of the script function): E.g: Function TextNotyet (TextName, Content) {//iff text Has Not Been MotiFied Return-1 IF (TextName.Value == ") { Alert ("Not filled in" Content; Return -1; } Else Return 0; } // function texTnotyet Function login () { // Log in to determine the button TextField, TextField2, TextField3 IF (TextNotyet (TextField, "Member User Name) || TextNotyet (TEXTFIELD2," Landing Password ") || TextNotyet (TextField3," Verify Password "))) // Call textNotyet () Return; Location = "Memberpassstep2.html"; // Jump } script> Seven, drop-down menu Dreamweaver itself has this drop-down menu jump function generating template, for example: select> Note: In this "MM_JUMPMENUGO ('website search table 2', 'parent', 1)" function, the first parameter is the form element SeleCename, the second is traget, ie Whether to open in this window or another new window, the third parameter is to determine if "SELECT First Item After Url Change" (0 -> Cancel, 1 -> Setting) There is also the "option value" of the drop-down menu, you must be the page file name to open! In addition, the system will automatically generate three functions and should be a layer function. 8. There are two kinds of forms of forms of forms. First: Processing directly through the action = "related pages" and submit submitting buttons through the form of
Second: If the picture button, let the picture connect to a JavaScript function, like this:
Then use this statement to submit form data in function (): Document.FormName.Submit (); (because we change all buttons to images, this method
Maybe we have to use more! )
The following is a method of submission of a form:
POST Submit all POST submission can only be generated in Form, submitting two types: Direct submission (Submit submission), indirect submission (script submission)
1) Directly Submit: Click the Submit button, immediately submit