2.document.forms
例 2.1(FormActionSubmitIEFF.html)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<TITLE></TITLE>
<SCRIPT LANGUAGE="JavaScript">
/*
JavaScript syntax: - myObject.onclick = aHandler
HTML syntax: <A onClick="..."> <AREA onClick="..."> <HTMLTag onClick="..."> <INPUT onClick="...">
Form object (Object/HTML)
An object representing an HTML <FORM> tag.
*/
function clickH(actUrl)
{
/*Document.forms[] (Collection)
An array containing a list of all the forms in the document.*/
var fm = document.forms[0];
/*Form.action (Property)
A property that contains the submit action method for the <FORM>.
JavaScript syntax: - myForm.action
HTML syntax: <FORM ACTION="...">
*/
fm.action = actUrl;
/*Form.submit() (Method)
Invoke a form submit to the server.*/
fm.submit();
}
</SCRIPT>
</HEAD>
<BODY>
<FORM METHOD=POST>
<input name="name" type="text"/><br>
<input type="button" value="提交到第一个地址" onClick="clickH('1.htm?k=b')"/>
<input type="button" value="提交到第二个地址" onClick="clickH('2.htm')"/>
</FORM>
</BODY>
</HTML>
例 2.2(FormObjectReferenceIEFF.html)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<SCRIPT LANGUAGE="JavaScript">
<!--
function test()
{
var txt1 = document.forms[0].elements[0].value
var txt2 = document.regForm.username.value
var psw1 = document.forms[0].elements[1].value
var psw2 = regForm.psw.value;
with(document)
{
write("document.forms[0].elements[0].value-->"+txt1+"<br>")
write("document.regForm.username.value-->"+txt2+"<br>")
write("document.forms[0].elements[1].value-->"+psw1+"<br>")
write("regForm.psw.value-->"+psw2+"<br>")
}
}
更多内容请见原文,文章转载自:https://blog.csdn.net/qq_43650923/article/details/103046648
相关文章
- 07-26MapReduce当中Combiner的用法
- 07-26MapReduce当中的reduce当中的cleanup的用法
- 07-26jquery当中toggleClass的用法
- 07-26Spark Scala当中reduceByKey的用法
- 07-26jquery当中append的用法
- 07-26【JavaScript流程控制语句的用法及练习】
- 07-26Javascript的console.log()用法
- 07-26javascript中的innerHTML是什么意思,怎么个用法?
- 07-26JavaScript中return的用法和this的用法详解
- 07-26Javascript模块化编程(三):require.js的用法(转)