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

          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 訪問表單中的文本框內容

          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)復制文本框內容

          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 閱讀(434) 評論(2)  編輯  收藏 所屬分類: js

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

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

          常用鏈接

          留言簿(4)

          隨筆分類

          隨筆檔案

          好友的blog

          搜索

          •  

          積分與排名

          • 積分 - 118111
          • 排名 - 499

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 抚宁县| 浙江省| 枞阳县| 永泰县| 濉溪县| 尚义县| 大竹县| 漳州市| 崇州市| 和平区| 准格尔旗| 富民县| 樟树市| 河源市| 麻江县| 红原县| 正宁县| 龙里县| 大竹县| 天门市| 泸溪县| 宣恩县| 宁津县| 郓城县| 平湖市| 花莲县| 天水市| 城口县| 青田县| 青铜峡市| 巴楚县| 云梦县| 正定县| 石首市| 安泽县| 遂溪县| 外汇| 黑山县| 龙口市| 津市市| 鹤峰县|