zoukankan      html  css  js  c++  java
  • javascript上实现动态参数

    最近在项目中用了JS模板技术,用JS和AJAX驱动来实现前端和后台的分离,实现UI的多样化定制功能。

    以下记录实现通过参数多态的方式获取页面的元素给AJAX后端参数赋值。

        function myFunction(test1,test2)  
        {  
            var jh_input = document.getElementById(test1);
           alert(jh_input.value);
                  
            var t2 = document.getElementById(test2);
            alert(t2.value);              
        }
       function extendFunction(callbackFunction,extend)  
       {  
           var extendStr = "this is extend string!";  
           var args = [];  
           if(typeof(extend) == "object")  
           {  
               for (var property in extend)  
               {                
                   callbackFunction[property] = extend[property];              
                   args.push(extend[property]);  
               }  
           }        
           callbackFunction["extendStr"] = extendStr;          
           args.push(extendStr);
           callbackFunction.apply(this,args);  
       }  
      </script>

    <form id=frm>
    <div id=els>
    <input type=text id=txt_name />
    <input type=text id=txt_pwd />
    </div>
    <input type=button value=submit onclick="javascript:extendFunction(myFunction,{name:'txt_name',pwd:'txt_pwd'});  "; />
    </body>
  • 相关阅读:
    Opportunities
    去考試6/16
    WP数据绑定 GIS
    wp 之path详细 以及一个关于LinearGradientBrush 的动画 GIS
    windows phone 多触控画图并保存到 手机图片库 GIS
    windwos phone 的多任务 GIS
    导航基础 GIS
    Windows Phone 7 页面旋转动画 GIS
    一个小范围 滑动的动画 GIS
    wp 的手势Gestures: flick, pan, and stretch GIS
  • 原文地址:https://www.cnblogs.com/Leung/p/1699954.html
Copyright © 2011-2022 走看看