• 几个javascript函数


    1.功能说明:根据控件类型和名字(根据title值)查找控件

    使用举例:getField('select', 'Segment Code').value = "";

     function getField(fieldType,fieldTitle)

    {
        var docTags = document.getElementsByTagName(fieldType);
        for (var i=0; i < docTags.length; i++)

      {
          if (docTags[i].title == fieldTitle)

         {
            return docTags[i]
          }
        }
      }

    2.自定义控件客户端事件的写法:

    getField('input', 'Master No').onchange=function(){GetCustomerInfoByID(getField('input', 'Master No').value)};

    3. 一个ajax函数,利用webservice通过参数得到返回值:

    webservice地址:http://cntsnapp102.zone1.scb.net:9990/Service1.asmx

    函数名称:GetCustomerInfoByID(string id)

      function GetCustomerInfoByID(ID)
      {
            var data;
            data = '<?xml version="1.0" encoding="utf-8"?>';
            data = data + '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';
            data = data + '<soap:Body>';
            data = data + '<GetCustomerInfobyID xmlns="http://tempuri.org/">';
            data = data + '<sCustomerID>'+ID+'</sCustomerID>';
            data = data + '</GetCustomerInfobyID>';
            data = data + '</soap:Body>';
            data = data + '</soap:Envelope>';

            var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            var URL="http://cntsnapp102.zone1.scb.net:9990/Service1.asmx?op=GetCustomerInfobyID&sCustomerID=" + ID;
           
            //alert(URL);
            xmlhttp.Open("POST",URL, false);
            xmlhttp.SetRequestHeader ("Content-Type","text/xml; charset=utf-8");
            xmlhttp.SetRequestHeader ("SOAPAction","http://tempuri.org/GetCustomerInfobyID");
            xmlhttp.Send(data);
            //alert(xmlhttp.responseText);
            var oDoc = new ActiveXObject("MSXML2.DOMDocument");//Microsoft.XMLDOM

            oDoc.loadXML(xmlhttp.responseText);
         
            var nodeTags;
            nodeTags = oDoc.getElementsByTagName("GetCustomerInfobyIDResult");
            //alert('Result ' + nodeTags(0).childNodes[0].text);

            var xmlObj = oDoc.documentElement;
            //getField('input', 'Company').value = xmlObj.childNodes(0).childNodes(0).text;
            var strInfo=xmlObj.childNodes(0).childNodes(0).text.split("|");
            if(strInfo!="")
            {
               getField('input', 'Company').value = strInfo[0];
               getField('input', 'Organization Code').value = strInfo[3];
               getField('input', 'Debt No').value = strInfo[4];
               getField('select', 'Segment Code').value = strInfo[2];
               getField('input', 'Company Property').value = strInfo[6];
            }
            else
            {
               getField('input', 'Company').value = "";
               getField('input', 'Organization Code').value = "";
               getField('input', 'Debt No').value = "";
               getField('select', 'Segment Code').value = "";
            }
        
            xmlhttp = null;
       }

  • 相关阅读:
    特性(Attribute)
    泛型
    AngularJS 基础用法
    js date相关学习!
    android 数据存储分配的一些事
    angularjs model.service vs provider vs factory?
    angularJS 判断
    zepto.js 学习之(一)
    angularJS Directive学习
    AngularJS继续中
  • 原文地址:https://www.cnblogs.com/catvi/p/1952954.html
Copyright © 2020-2023  润新知