国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > JS > 正文

JS初學者實例教程(6):Document對象讀取表單元素

2024-09-06 12:40:51
字體:
供稿:網(wǎng)友

上一篇js教程學習了:javascript初學者實例教程(5):document對象

實例六

本實例主要介紹了document對象讀取表單元素的使用

 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
 <head>
  <title> new document </title>
  <script language="javascript">
  <!--
 function firstsubmit(){
 alert(document.form1.a01.value);//將表單名為a01的值顯示出來
 }
 function copyfirstsubmit(){
 alert(document.form1.a01.value);
    document.form1.a02.value=document.form1.a01.value;//將表單名為a01的值給a02,取a01的值也可以使用、、、//document.form1.elements[0].value
 }
  //-->
  </script>
 </head>
 <body>
  <form name="firstform" method=post action="">
 <input type="text" name="firsttext" value="哈啰">
  </form>
 
  <form name="secondform" method=post action="">
 <input type="text" name="secondtext" value="哈啰">
 <input type="submit" name="hehe" value="哈哈">
  </form>
  <script language="javascript">
<!--
 var first = document.firstform.name;
 var second = document.secondform.name;
 //alert("第一個表單的名字:"+first);//讀取表單元素,將注釋去點即可
 //alert("第二個表單的名字:"+second);
 //alert("第二個表單的按鈕的name是:"+document.secondform.elements[1].name);
 //alert("第二個表單文本域的值:"+document.secondform.elements[0].value);
 //alert("第一個文本域:"+document.firstform.firsttext.value);
//-->
</script>
<form name="form1" method=post action="">
 a01<input type="text" name="a01"/><input type="button" name="01s" value="提交" onclick="firstsubmit()"/><br/>
 a02<input type="text" name="a02"/><input type="button" name="02s" value="提交" onclick="copyfirstsubmit()"/>×在a01中輸入值后再提交
</form>
 </body>
</html>

效果演示:


[ctrl+a 全部選擇 提示:你可先修改部分代碼,再按運行]

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 大厂| 乐陵市| 宁陵县| 萝北县| 普定县| 英超| 治县。| 湘潭县| 黄陵县| 宁德市| 从化市| 西林县| 新化县| 扶绥县| 长丰县| 北辰区| 乐业县| 达日县| 山东省| 竹溪县| 巧家县| 怀柔区| 凤阳县| 夏津县| 宜昌市| 涪陵区| 雷波县| 陵川县| 开鲁县| 连城县| 久治县| 普定县| 高淳县| 冀州市| 伽师县| 杭锦后旗| 新田县| 新平| 延边| 鹿泉市| 崇文区|