⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex11-7.htm

📁 有关JAVASCRIPT的源代码教程
💻 HTM
字号:
    <html><head><title>通过名称访问form对象及其元素 </title></head>
    <body>
    <form name="myForm1">
        请输入一段文字:
        <input name="txtenter" size="40"
           type="text"
           value="新妆宜面下朱楼,深锁春光一院愁。">
    </form>
    <form name="myForm2">
        <input type="button" name="button1" value="红色"></input>
        <input type="button" name="button2" value="绿色"></input>
        <input type="button" name="button3" value="蓝色"></input>
    </form>
    <script language="JavaScript">
       <!--        
        document.write("<b>表单1名称为:</b><em>"
        +document.myForm1.name);
        document.write("</em><b><br>表单1中输入域的个数为: </b><em> "
        +document.myForm1.length);
        document.write("</em><b><br>单行文本框的值为: </b><em> "
        +document.myForm1.txtenter.value);        
        document.write("</em><b><br>表单2中按钮的个数为: </b><em> "
        +document.myForm2.length);
        document.write("</em><b><br>按钮button2的值为: </b><em> "
        +document.myForm2.button2.value);
        document.write("</em><br><br><b>第一个表单document.forms[0]的名称为:</b>",
           document.forms[0].name);
        document.write("<br><b>第二个表单document.forms[1]的名称为:</b>", 
          document.forms[1].name);
        document.write("<p><b>下面给出elements[]数组各元素的name、type和value属性值: <em>");
            for(var i = 0; i < document.myForm2.length; i++){
               document.write("<br>name属性值为:" +
               document.myForm2.elements[i].name +"<br>");
               document.write("value属性值为:"
               +document.forms[1].elements[i].value+"<br>");
               document.write("type属性值为:"
               +document.forms[1].elements[i].type +"<br>");
            }
            document.write("</em></b>");
       //-->        
    </script>
    </body>
    </html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -