最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

DWR  util.js 學(xué)習(xí)筆記 整理

 更新時(shí)間:2007年05月07日 00:00:00   作者:  
util.js包含一些有用的函數(shù)function,用于在客戶端頁(yè)面調(diào)用,它可以和dwr分開,獨(dú)立營(yíng)用于你的系統(tǒng)中。

主要功能如下:
1、$() 獲得頁(yè)面參數(shù)值
2、addOptions and removeAllOptions 初始化下拉框
3、addRows and removeAllRows  填充表格
4、getText  取得text屬性值
5、getValue 取得form表單值
6、getValues 取得form多個(gè)值
7、onReturn  
8、selectRange
9、setValue
10、setValues
11、toDescriptiveString
12、useLoadingMessage
13、Submission box

***************************************************************************************
//////////////////////////////////////////////////////////////////////////////////////
****************************************************************************************
1、$()函數(shù)
  IE5.0 不支持
  $ = document.getElementById
  取得form表單值
  var name = $("name");
***************************************************************************************
//////////////////////////////////////////////////////////////////////////////////////
****************************************************************************************
2、用于填充 select 下拉框 option
  a、如果你想在更新select 時(shí),想保存原來(lái)的數(shù)據(jù),即在原來(lái)的select中添加新的option:
     var sel = DWRUtil.getValue(id);
     DWRUtil.removeAllOptions(id);
     DWRUtil.addOptions(id,...);
     DWRUtil.setValue(id,sel);
     demo:比如你想添加一個(gè)option:“--請(qǐng)選擇--”
    DWRUtil.addOptions(id,["--請(qǐng)選擇--"]);    

    DWRUtil.addOptions()有5中方式:

    @ Simple Array Example: 簡(jiǎn)單數(shù)組
      例如:
      Array array = new Array[ 'Africa', 'America', 'Asia', 'Australasia', 'Europe' ];
      DWRUtil.addOptions("demo1",array);

    @ Simple Object Array Example 簡(jiǎn)單數(shù)組,元素為beans
      這種情況下,你需要指定要顯示 beans 的 property 以及 對(duì)應(yīng)的 bean 值
      例如:
       public class Person {
     private String name;
     private Integer id;
     pirvate String address;
     public void set(){……}
     public String get(){……}
       }
       DWRUtil.addOptions("demo2",array,'id','name');
       其中id指向及bean的id屬性,在optiong中對(duì)應(yīng)value,name指向bean的name屬性,對(duì)應(yīng)下拉框中顯示的哪個(gè)值.

     @ Advanced Object Array Example 基本同上
    DWRUtil.addOptions( "demo3", 
                [{ name:'Africa', id:'AF' },
                 { name:'America', id:'AM' },
                 { name:'Asia', id:'AS' },
                 { name:'Australasia', id:'AU' },
                 { name:'Europe', id:'EU' }
        ],'id','name');

     @ Map Example 用制定的map來(lái)填充 options:
       如果 server 返回 Map,呢么這樣處理即可:
       DWRUtil.addOptions( "demo3",map);
       其中 value 對(duì)應(yīng) map keys,text 對(duì)應(yīng) map values;

     @ <ul> and <ol> list editing

       DWRUtil.addOptions() 函數(shù)不但可以填出select,開可以填出<ul>和<ol>這樣的heml元素

***************************************************************************************
//////////////////////////////////////////////////////////////////////////////////////
****************************************************************************************
3、addRows and removeAllRows  填充表格
   DWR 提供2個(gè)函數(shù)來(lái)操作 table;
   ----------------------------
   DWRUtil.addRows(); 添加行
   ----------------------------
   DWRUtil.removeAllRows(id); 刪除指定id的table
   ----------------------------
   下面著重看一下 addRows() 函數(shù):

   DWRUtil.addRows(id, array, cellfuncs, [options]);
    其中id 對(duì)應(yīng) table 的 id(更適合tbodye,推薦使用 tbodye)
    array 是server端服務(wù)器的返回值,比如list,map等等
    cellfuncs 及用返回值來(lái)天春表格
    [options] 用來(lái)設(shè)置表格樣式,它有2個(gè)內(nèi)部函數(shù)來(lái)設(shè)置單元格樣式(rowCreator、cellCreator)。

    比如: server端返回list,而list中存放的是下面這個(gè) bean:
        public class Person {
     private String name;
     private Integer id;
     pirvate String address;
     public void set(){……}
     public String get(){……}
       }

    下面用  DWRUtil.addRows(); 
   /**************************************************************************************/
   /****************** 胡國(guó)清***********fzfx88@hotmail.com********************************/
   /**************************************************************************************/

   function userList(data){
    //var delButton = "<input type='button'/>";
    //var editButton = "<input type='button'/>";
    var cellfuncs = [
        function(data){return data.id;},
        function(data){return data.userName;},
        function(data){return data.userTrueName;},
        function(data){return data.birthday;},
        function(data){
            var idd = data.id;
            var delButton = document.createElement("<INPUT TYPE='button' onclick='delPerson("+ idd +")'>");
            delButton.setAttribute("id","delete");
            delButton.setAttribute("value","delete");
            return delButton;
        },
        function(data){
            var idd = data.id;
            var editButton = document.createElement("<INPUT TYPE='button' onclick='editPerson("+ idd +")'>");
            editButton.setAttribute("name","edit");
            editButton.setAttribute("value","edit");            
            return editButton;
        }
    ];
    DWRUtil.removeAllRows('tabId');    
    DWRUtil.addRows('tabId', data,cellfuncs,{
    rowCreator:function(options) {
        var row = document.createElement("tr");
        var index = options.rowIndex * 50;
        row.setAttribute("id",options.rowData.id);
        row.style.collapse = "separate";
        row.style.color = "rgb(" + index + ",0,0)";
        return row;
      },
      cellCreator:function(options) {
        var td = document.createElement("td");
        var index = 255 - (options.rowIndex * 50);
        //td.style.backgroundColor = "rgb(" + index + ",255,255)";
        td.style.backgroundColor = "menu";
        td.style.fontWeight = "bold";
        td.style.align = "center";
        return td;
      }        
    });
    document.getElementById("bt").style.display = "none";
     }
     待續(xù)…………………………………………
   /**************************************************************************************/
   /**************************************************************************************/
   /**************************************************************************************/
   4、getText  取得text屬性值

      DWRUtil.getText(id): 用來(lái)獲得 option 中的文本
      比如:
       <select id="select">
    <option  value="1"> 蘋果 </option>
    <option  value="2" select> 香蕉 </option>
    <option  value="3"> 鴨梨 </option>
       </select>
      調(diào)用 DWRUtil.getText("select"); 將返回 "香蕉" 字段;
      DWRUtil.getText(id);僅僅是用來(lái)獲得 select 文本值,其他不適用。
   /**************************************************************************************/
   /**************************************************************************************/
   /**************************************************************************************/

   5、DWRUtil.getValue(id): 用來(lái)獲得 form 表單值

      有如下幾種情況:
          Text area (id="textarea"): DWRUtil.getValue("textarea")將返回 Text area的值;
      Selection list (id="select"): DWRUtil.getValue("select") 將返回 Selection list 的值;
      Text input (id="text"): DWRUtil.getValue("text") 將返回 Text input 的值;
      Password input (id="password"): DWRUtil.getValue("text") 將返回 Password input 的值;
      Form button (id="formbutton"): DWRUtil.getValue("formbutton") 將返回 Form button 的值;
      Fancy button (id="button"): DWRUtil.getValue("formbutton") 將返回 Fancy button 的值;
   /**************************************************************************************/
   /**************************************************************************************/
   /**************************************************************************************/

   6、getValues 取得form多個(gè)值
      批量獲得頁(yè)面表單的值,組合成數(shù)組的形式,返回 name/value;

      例如: form():
       <input type="textarea" id="textarea" value="1111"/>
       <input type="text" id="text" value="2222"/>
       <input type="password" id= "password" value="3333"/>
       <select id="select">
    <option  value="1"> 蘋果 </option>
    <option  value="4444" select> 香蕉 </option>
    <option  value="3"> 鴨梨 </option>
       </select>
       <input type="button" id="button" value="5555"/>

      那么: DWRUtil.getValues({textarea:null,select:null,text:null,password:null,button:null})
      將返回  ^^^^^^^^^^^^^^^^{textarea:1111,select:4444,text:2222,password:3333,button:5555}

    
   /**************************************************************************************/
   /**************************************************************************************/
   /**************************************************************************************/

   7、DWRUtil.onReturn 防止當(dāng)在文本框中輸入后,直接按回車就提交表單。

     <input type="text" onkeypress="DWRUtil.onReturn(event, submitFunction)"/>
     <input type="button" onclick="submitFunction()"/>

   /**************************************************************************************/
   /**************************************************************************************/
   /**************************************************************************************/

   8、DWRUtil.selectRange(ele, start, end);

      在一個(gè)input box里選一個(gè)范圍 

      DWRUtil.selectRange("sel-test", $("start").value, $("end").value);

      比如:<input type="text" id="sel-test" value="012345678901234567890">

      DWRUtil.selectRange("sel-test", 2, 15); 結(jié)果 文本框中的值"2345678901234"將被選中'

   /**************************************************************************************/
   /**************************************************************************************/
   /**************************************************************************************/

   9、DWRUtil.setValue(id,value);
      為指定的id元素,設(shè)置一個(gè)新值;
   /**************************************************************************************/
   10、DWRUtil.setValues({  
    name: "fzfx88", 
    password: "1234567890" 
    }
       ); 同上,批量更新表單值.
   /**************************************************************************************/

   11、DWRUtil.toDescriptiveString()

   帶debug信息的toString,第一個(gè)為將要debug的對(duì)象,第二個(gè)參數(shù)為處理等級(jí)。等級(jí)如下: 

    0: Single line of debug 單行調(diào)試  
    1: Multi-line debug that does not dig into child objects 不分析子元素的多行調(diào)試  
    2: Multi-line debug that digs into the 2nd layer of child objects 最多分析到第二層子元素的多行調(diào)試 

    <input type="text" id="text">
    DWRUtil。toDescriptiveString("text",0);
   /**************************************************************************************/

   12、DWRUtil.useLoadingMessage();
    當(dāng)發(fā)出ajax請(qǐng)求后,頁(yè)面顯示的提示等待信息;

    function searchUser(){
    var loadinfo = "loading....."
    try{
        regUser.queryAllUser(userList);
        DWRUtil.useLoadingMessage(loadinfo);        
    }catch(e){

    }
    }

    /**************************************************************************************/ 


   

相關(guān)文章

  • ajax 亂碼的一種解決方法

    ajax 亂碼的一種解決方法

    第一次碰到了這種編碼的問題,在windows下AJAX接收到中文數(shù)據(jù)顯示出來(lái)全是亂碼,而在linux下,竟然提示網(wǎng)頁(yè)出錯(cuò),什么顯示都沒有。
    2009-06-06
  • ajax三級(jí)聯(lián)動(dòng)下拉菜單效果

    ajax三級(jí)聯(lián)動(dòng)下拉菜單效果

    這篇文章主要為大家詳細(xì)介紹了ajax三級(jí)聯(lián)動(dòng)下拉菜單的相關(guān)資料,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-03-03
  • ajax的工作原理以及異步請(qǐng)求的封裝介紹

    ajax的工作原理以及異步請(qǐng)求的封裝介紹

    客戶端通過瀏覽器的內(nèi)置對(duì)象XMLHttpRequest來(lái)發(fā)送異步請(qǐng)求,當(dāng)服務(wù)器返回響應(yīng)時(shí),會(huì)調(diào)用先前注冊(cè)的回調(diào)函數(shù),異步請(qǐng)求不會(huì)阻塞客戶端的操作,達(dá)到頁(yè)面無(wú)法刷新就可以更新數(shù)據(jù)的效果
    2013-09-09
  • AJAX 常用函數(shù)

    AJAX 常用函數(shù)

    AJAX 常用函數(shù)...
    2007-01-01
  • Ajax方式刪除表格一行數(shù)據(jù)示例代碼

    Ajax方式刪除表格一行數(shù)據(jù)示例代碼

    Ajax方式刪除信息在某些情況下還是蠻實(shí)用的,下面為大家具體介紹下Ajax方式如何刪除表格一行數(shù)據(jù),感興趣的朋友可以了解下
    2013-08-08
  • Ajax學(xué)習(xí)筆記整理

    Ajax學(xué)習(xí)筆記整理

    Ajax: Asynchronous JavaScript and Xml , 異步j(luò)s腳本和xml , 常用來(lái)實(shí)現(xiàn)頁(yè)面局部的異步刷新, 對(duì)提高用戶體驗(yàn)有很大幫助. Xml在多語(yǔ)言時(shí)較有優(yōu)勢(shì), 但Ajax技術(shù)實(shí)際上較多采用Json對(duì)象而不是Xml來(lái)處理數(shù)據(jù)
    2016-01-01
  • Ajax異步檢查用戶名是否存在

    Ajax異步檢查用戶名是否存在

    這篇文章主要為大家詳細(xì)介紹了Ajax異步檢查用戶名是否存在的相關(guān)方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-11-11
  • ajax Suggest類似google的搜索提示效果

    ajax Suggest類似google的搜索提示效果

    實(shí)現(xiàn)了類似google的搜索提示效果。
    2009-03-03
  • JQuery的ajax的用法在asp中使用$.ajax()實(shí)現(xiàn)

    JQuery的ajax的用法在asp中使用$.ajax()實(shí)現(xiàn)

    ajax的出現(xiàn)解決了很多的疑難問題,同時(shí)帶來(lái)了很多的方便,本文講述一下JQuery的ajax的用法在asp中使用$.ajax()來(lái)表示,感興趣的朋友可以了解下,或許本文對(duì)你有所幫助
    2013-01-01
  • ajax傳送參數(shù)含有特殊字符的快速解決方法

    ajax傳送參數(shù)含有特殊字符的快速解決方法

    下面小編就為大家?guī)?lái)一篇ajax傳送參數(shù)含有特殊字符的快速解決方法。希望對(duì)大家有所幫助,一起跟隨小編過來(lái)看看吧
    2016-04-04

最新評(píng)論

盐边县| 星座| 景洪市| 呼玛县| 韶山市| 同江市| 邳州市| 凤翔县| 德庆县| 双城市| 县级市| 西青区| 虞城县| 隆安县| 天祝| 安徽省| 册亨县| 海晏县| 长沙县| 宜良县| 抚顺县| 安国市| 屯留县| 民和| 鹤岗市| 苏尼特右旗| 灌南县| 化州市| 资中县| 河源市| 邵东县| 登封市| 祁门县| 土默特左旗| 高州市| 沾化县| 松阳县| 永靖县| 菏泽市| 镇宁| 麦盖提县|