?? ??
form ??
<form> ??? <form>
?? ??? ??
name: ?? ??. ?? JS?? ??? ???? ??? ?????.
action: ?? ??? ?? ????(PHP ??).
method: ?? ?? ??, ?: GET, POST
enctype: ?? ???? ??? ??.
?? ??? ??
submit(): <?? ?? = “submit” />? ??? ??? ?? ??? ?????.
reset(): ??? ??? ??? ??? ?? ??? ??????.
?? ?? ???
onsubmit: ?? ??? ??? ? ???? ???? ??? ???? ?? ?????. ?? "?? ?? ? ?? ??? ??"? ?????.
onreset: ??? ??? ???? ?????.
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>php.cn</title> <script type="text/javascript"> window.onload = function(){ //獲取form對(duì)象 var formObj = document.form1; //增加method屬性 formObj.method = "post"; //增加action屬性 formObj.action = "login.php"; } </script> </head> <body> <form name="form1"> 用戶名:<input type="text" name="username" /> 密碼:<input type="password" name="userpwd" /> <input type="submit" value="提交表單" /> </form> </body> </html>
?? ?? ????
? ??? ID? ?? ??? ?????. document.getElementById(id)
HTML ?? ??? ?? ??? ?????. parentNode.getElementsByTagName(tagName)
name ??? ?? ?? ?? ??? ?????. ??? ?? ?? ??? ???? ?? ???? ???.
??: ??document.formObj.elementObj
??? ??? 3?? ?????. ? ? formObj? ? ??? ????, elementObj? ? ?? ??? ????.
?: document.form1.username.value.length
??? ?? ?
???? ?? ?? ??? ?? ??? ??? ????. ?: <a> ??? ?? ??? URL? ?? ????.
???? false? ???? ?? ??? ??? ????, ???? true? ????? ?? ??? ?? ??? ?? ?????.
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>php.cn</title> </head> <body> <a href="http://miracleart.cn" onclick="return false">PHP中文網(wǎng)</a> </body> </html>
?? ?? ??? ?? ? ?? ???? onclick? onsubmit???.