7-1 表單?其屬性??質

ڭ̦be`wg²aйLAѩOϥΪ̻PAʪDnAҥHڭ̷|boӳ`JӦaЪAרO椺Uر]Controls^AHΨݩʻPʽC

]Forms^OϥΪ̸gѺPAi椬ʪ̱`覡C@ӻAϥΪ̥gѪ檺gA~NȤݪưe^AݡC@²檺lXpUG

<form name=formName id=formId method=post action=example/formact.asp target=_blank> QmjWG<input type=text name=UserName value="Test Input"> <input type=submit> <input type=reset> </form> be{ĪGpUG
bWҤA@ϥΪ̫UueXdߡvsAsNN椸ȡ]ҦpWzdҤuTest Inputv^e^AAæbAHuexample/formact.aspv{XӳBz쪺TA̫NBzG^ǵsCABzƪӸ`Aڭ̷|bѲĤGgPA`̦ԲӪC

Ҧb HTML lXiH\hݩʡ]Attributes^AҦp name N檺W١Amethod NsNưeܦA覡Aaction NbAݡBtdBzƪ{ɡAtarget hNA^ǸƫAΤݥΩe{ƪW١Cbϥ JavaScript VBScript ɡAQ@ӪAYUةʽ]Properties^Mk]Methods^CҪݩʩM檫󪺩ʽAXGۤ@@YA`NOAݩʬOΩ HTMLAөʽhOΦb JavaScript VBScript CHUNw`ΪuҪݩʡvMu檫󪺩ʽviCC

Ҫݩʤλ
Ҫݩ檫ʽλ
name 檺W١AiQ JavaScript VBScript ΥHsΨC ҦpAڭ̥i document.formName άO document.forms["formName"] Өo檫C
id 檺W١AiQ JavaScript VBScript ΥHsΨC ϥ id ɡAڭ̥iHg DOM h[cӨo檫AҦpAڭ̥iHϥ document.getElementById(formId) άO document.all["formId"] Өo檫Cid ȦbӺOߤ@AHקKML󲣥ͽĬC
target A^ǸTX{mAiHO@ӵ (Window)Bج[ (Frame)AάO _topB_parentB_selfB_blankCYLݩʡAAh^ǵGNX{C ʽO targetAҦpG
action wAݪBz{CBz{iHW@xAA]iHϥ mailto:xxx@xxx.xxx 覡ӱNTgѹqllHXC ʽO actionAҦpG
method wƶǰe覡Aiؤ覡G
  • get: Ƹg QUERY_STRING ܼưeܦAAoOw]覡AǰeƶqAq`u 1 KB kC
  • post: Ƹg standard input ǰeAƪxs CONTENT_LENGTH ܼơAǰeƥij 1 MBC
ʽO methodAҦpG
enctype w MIME sX覡ӶǰeơAiHحȡG"application/x-www-form-urlencoded" (w]) "multipart/form-data"C ʽO encodingAҦpG
onSubmit JavaScript VBScript ƥBzAY^ǭȬ falseAhN|QeXCݩʳq`ΨˬdϥΪ̩ҶJƬO_TAYTANNưeAC ʽO onSubmitC

~A檫]@ǩʽAOLkMҹAҦp elements]Ѫ椸ҧΦ}C^M Length]椸Ӽơ^AHUڭ̦CX@Ӫ檫󪺩ҦʽAjaѦҡG

Example]formProp01.htm^G

lXG

lɡ]formProp01.htm^G]ǦϰUYi^
<html>
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=big5">
</head>

<body>
<h2 align=center>檺ʽC</h2>
<hr>
<form name=formName id=formId method=post action=formact.asp target=_blank>
	QmjWG<input type=text name=UserName value="Test Input">
	<input type=submit> <input type=reset>
</form>
<hr>

<script src="listProp.js"></script>
HUϥ listProp(formId, "formId") ӦCXWz檺ҦʽC
A]iHϥ listProp(document.formName, "document.formName") ӹFP˪\C
<p><h3>"document.formName" ʽCG</h3>
<p><script>listProp(formId, "formId")</script>

<hr>
</body>
</html>

MAHssA檺ʽ]|VӶVhA䤤̭nʽMO elementsAoNO椸]κٱ^ҧΦ}CAN|bU@`ԭzC

@ HTML iH]tƭӪA̦nΤPW١AH JavaScript VBScript ھڦW٨ӦsPCɭԬF{X²A]iH]w檺 name id ݩʡAɥiHϥ document.forms[0], document.forms[1], document.forms[2] ӨoĢBBӪA̦C

~AbϥΪ檫ɡAҼ{iܩج[]Frames^A]Τ@өʽ誺kG

window.parent.frames[0].document.forms[0].property
Oج[ϥΤ]OVӶV֡AҥHNiHo·СC
JavaScript {]pPΡGΩΤ