1. 程式人生 > >javascript_form 提交按鈕獲得用戶名

javascript_form 提交按鈕獲得用戶名

log 註意 class ner for type aid action htm

<!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=utf-8" />
<title>無標題文檔</title>
<script type="text/javascript
"> function ol() { var t=document.forms[0].elements[0].value; document.getElementById("jg").innerHTML=t; } </script> <scrip> </head> <body> <form name="form1" action="wwww.baidu.com" method="post"> <p>用戶名:<input type="text" name="username" id="uid" value="
用戶" /></p> <p>密&nbsp;&nbsp;&nbsp;&nbsp;碼:<input type="password" name="pwd" /></p> <input type="submit" value="提交" onclick="ol()" /> </form> <p id="jg"></p> </body> </html>

註意:這類題型都是通過調用函數(方法)來實現目的。通過函數實現功能,通過getElementById來確定獲取信息要顯示的頁面位置,通過 onclick調用該函數。函數的核心功能語句是利用逐步確定來獲取對象的屬性值,註意每步獲取屬性時用“.”隔開。

javascript_form 提交按鈕獲得用戶名