姿姿霸霸~~!
          貴在堅持!
          posts - 106,  comments - 50,  trackbacks - 0
          43 表單構(gòu)成

          1: <form method=”post” action=”target.html” name=”thisForm”>
          2: <input type=”text” name=”myText”>
          3: <select name=”mySelect”>
          4: <option value=”1”>First Choice</option>
          5: <option value=”2”>Second Choice</option>
          6: </select>
          7: <br>
          8: <input type=”submit” value=”Submit Me”>
          9: </form>


          44 訪問表單中的文本框內(nèi)容

          1: <form name=”myForm”>
          2: <input type=”text” name=”myText”>
          3: </form>
          4: <a href='#' onClick='window.alert(document.myForm.myText.value);'>Check Text Field</a>


          45 動態(tài)復(fù)制文本框內(nèi)容

          1: <form name=”myForm”>
          2: Enter some Text: <input type=”text” name=”myText”><br>
          3: Copy Text: <input type=”text” name=”copyText”>
          4: </form>
          5: <a href=”#” onClick=”document.myForm.copyText.value =
          6: document.myForm.myText.value;”>Copy Text Field</a>


          46 偵測文本框的變化

          1: <form name=”myForm”>
          2: Enter some Text: <input type=”text” name=”myText” onChange=”alert(this.value);”>
          3: </form>


          47 訪問選中的Select

          1: <form name=”myForm”>
          2: <select name=”mySelect”>
          3: <option value=”First Choice”>1</option>
          4: <option value=”Second Choice”>2</option>
          5: <option value=”Third Choice”>3</option>
          6: </select>
          7: </form>
          8: <a href='#' onClick='alert(document.myForm.mySelect.value);'>Check Selection List</a>


          48 動態(tài)增加Select項

          1: <form name=”myForm”>
          2: <select name=”mySelect”>
          3: <option value=”First Choice”>1</option>
          4: <option value=”Second Choice”>2</option>
          5: </select>
          6: </form>
          7: <script language=”JavaScript”>
          8: document.myForm.mySelect.length++;
          9: document.myForm.mySelect.options[document.myForm.mySelect.length - 1].text = “3”;
          10: document.myForm.mySelect.options[document.myForm.mySelect.length - 1].value = “Third Choice”;
          11: </script>


          49 驗證表單字段

          1: <script language=”JavaScript”>
          2: function checkField(field) {
          3: if (field.value == “”) {
          4: window.alert(“You must enter a value in the field”);
          5: field.focus();
          6: }
          7: }
          8: </script>
          9: <form name=”myForm” action=”target.html”>
          10: Text Field: <input type=”text” name=”myField”onBlur=”checkField(this)”>
          11: <br><input type=”submit”>
          12: </form>


          50 驗證Select項

          1: function checkList(selection) {
          2: if (selection.length == 0) {
          3: window.alert(“You must make a selection from the list.”);
          4: return false;
          5: }
          6: return true;
          7: }
          51 動態(tài)改變表單的action

          1: <form name=”myForm” action=”login.html”>
          2: Username: <input type=”text” name=”username”><br>
          3: Password: <input type=”password” name=”password”><br>
          4: <input type=”button” value=”Login” onClick=”this.form.submit();”>
          5: <input type=”button” value=”Register” onClick=”this.form.action = ‘register.html’; this.form.submit();”>
          6: <input type=”button” value=”Retrieve Password” onClick=”this.form.action = ‘password.html’; this.form.submit();”>
          7: </form>


          52 使用圖像按鈕

          1: <form name=”myForm” action=”login.html”>
          2: Username: <input type=”text” name=”username”><br>
          3: Password: <input type=”password”name=”password”><br>
          4: <input type=”image” src="/”login.gif"” value=”Login”>
          5: </form>
          6:


          53 表單數(shù)據(jù)的加密

          1: <SCRIPT LANGUAGE='JavaScript'>
          2: <!--
          3: function encrypt(item) {
          4: var newItem = '';
          5: for (i=0; i < item.length; i++) {
          6: newItem += item.charCodeAt(i) + '.';
          7: }
          8: return newItem;
          9: }
          10: function encryptForm(myForm) {
          11: for (i=0; i < myForm.elements.length; i++) {
          12: myForm.elements[i].value = encrypt(myForm.elements[i].value);
          13: }
          14: }
          15:
          16: //-->
          17: </SCRIPT>
          18: <form name='myForm' onSubmit='encryptForm(this); window.alert(this.myField.value);'>
          19: Enter Some Text: <input type=text name=myField><input type=submit>
          20: </form>




          posted on 2007-05-26 19:42 xrzp 閱讀(426) 評論(2)  編輯  收藏 所屬分類: js

          FeedBack:
          # re: js總結(jié)4(轉(zhuǎn))
          2007-07-02 20:02 | mars
          45、46我都試過了,好像有問題,歡迎和我交流,QQ 260859084  回復(fù)  更多評論
            
          # re: js總結(jié)4(轉(zhuǎn))
          2007-07-02 20:11 | mars
          不好意思 所有的雙引號都應(yīng)該是英文狀態(tài)下的  回復(fù)  更多評論
            

          <2007年5月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          常用鏈接

          留言簿(4)

          隨筆分類

          隨筆檔案

          好友的blog

          搜索

          •  

          積分與排名

          • 積分 - 117491
          • 排名 - 500

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 凌海市| 新巴尔虎左旗| 贵南县| 平凉市| 通海县| 波密县| 苍梧县| 宜州市| 鹤庆县| 深州市| 方城县| 长沙县| 固阳县| 大石桥市| 伊金霍洛旗| 明光市| 卫辉市| 望奎县| 马尔康县| 九江市| 沙田区| 台江县| 北碚区| 万全县| 界首市| 县级市| 隆昌县| 通海县| 江孜县| 鹤壁市| 梁山县| 龙川县| 健康| 漯河市| 德江县| 绵阳市| 洛宁县| 延长县| 贵德县| 蓝山县| 旬阳县|