国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 三河市| 泽州县| 淳化县| 武定县| 中卫市| 扎赉特旗| 昌邑市| 三门县| 通渭县| 包头市| 台中市| 铜梁县| 松江区| 九龙城区| 监利县| 吉木乃县| 吉木乃县| 通道| 西平县| 萍乡市| 武威市| 崇左市| 青海省| 崇左市| 新昌县| 镇赉县| 冷水江市| 扎兰屯市| 梅州市| 汾阳市| 堆龙德庆县| 略阳县| 雷波县| 政和县| 固始县| 施秉县| 冕宁县| 同江市| 枣庄市| 海兴县| 云龙县|