Real JavaScript Primer · Introduction to document objects (access to the form, create a new page, get the page title) in the article, we've got some basic access to the form, and we're going to drill down to the properties of the form and the simple operation of the form element.
Demo One: According to demand, custom form
You first press the submit submission form, back up, then click to modify the form, and then submit the form, see the effect
Now the point is test.asp, the method is post
Actually do so much not, directly make two attributes Bar Tianhongkun blog NetEase get post
Demo Two: Modify the value of a particular type of element within a form
Form.elements[] Property: In addition to tracking each type of element in a form, the browser retains a list of all the control elements in the form, and the order of the elements is in the HTML position, so it is quite handy for references.
<% @LANGUAGE = "JAVASCRIPT" codepage= "936"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
< html xmlns = "http://www.w3.org/1999/xhtml" >
< head >
< meta HTTP-EQUIV = "Content-type" Content = "text/html"; charset=gb2312 "/>
< title > Form details One (modify form properties, modify form element values) </title >
< SCRIPT language = "JavaScript" >
function Gaibian ()
{
var Acti=document.getelementbyid ("select"). value;//get a value with the ID SELECT element
var Mont=document.getelementbyid ("Select2"). value;//ditto
document.form1.action=acti;//Set Value
document.form1.method=mont;//ditto
}
function Bian ()
{
Var form=document.forms[1];//assigns the second form of the current page to the variable form for later reference
for (var i=0;i<form.elements.length;i++)//Loop the largest item in an array of elements within a form
{
if (form.elements[i].type== "text")//if the type of the current element is text
{
Form.elements[i].value= "Tianhongkun";//Then give his value to Tianhongkun.
}
if (form.elements[i].type== "checkbox")//If check box
{
if (form.elements[i].checked)//If selected
{
form.elements[i].checked=null;//Cancel Selection
}
Else
{
Form.elements[i].checked= "Checked"//Just give him a check.
}
}
}
}
</script >
< BODY >
< P