zoukankan      html  css  js  c++  java
  • 通过XML数据进行异步提交并对XML数据进行处理

     <script language="javascript" type="text/javascript">

    var divSelectMark;
    var flag = 0;

    function showSelectMark(id)
    {
     var strFormApproveID = id.substring(3,id.length);
     //alert(strFormApproveID);
     divSelectMark = document.getElementById("divMark"+strFormApproveID);

     if(document.getElementById(id) == null )
     {
      return;
     }
     flag = 1;
     //if(divSelectMark.style.visibility == "hidden")
     //{
      divSelectMark.style.visibility = "visible";
      var distance = document.getElementById("contentList").getBoundingClientRect().bottom-document.getElementById(id).getBoundingClientRect().bottom
      if(distance<100)
      {
       divSelectMark.style.top = document.getElementById(id).getBoundingClientRect().top-100;
      }
      else
       divSelectMark.style.top = document.getElementById(id).getBoundingClientRect().bottom;
      divSelectMark.style.left = document.getElementById(id).getBoundingClientRect().left;
      
     /*}
     else
     {
      hideSelectMark();
     }*/
      
    }


    function hideSelectMark()
    {
     if(flag!=0)
      divSelectMark.style.visibility = "hidden";
    }

    function selectImageMark(id,type)
    {
     hideSelectMark();
     var strFormApproveID;
     
     if(document.getElementById(id) == null)
      return;
     var oldimage = document.getElementById(id).src;
     var newimage;
     var newflag ;
     var level1image =  "RedMark.gif";
     var level4image =  "NoneMark.gif";
     var level2image =  "YellowMark.gif";
     var level3image =  "GreenMark.gif";
     if(type == 0)
     {
      strFormApproveID = id.substring(3,id.length);
      
      if(oldimage.indexOf(level4image)>0)
      {
       newimage  =  level1image;
       newflag = 1;
      }
      else
      {
       newimage = level4image;
       newflag = 4;
      }
     }
     else
     {
      strFormApproveID = id.substring(6,id.length);
      if(oldimage.indexOf(level4image)>0)
      {
       newimage = level4image;
       newflag = 4;
      }
      else if(oldimage.indexOf(level1image)>0)
      {
       newimage = level1image;
       newflag = 1;
      }
      else if(oldimage.indexOf(level2image)>0)
      {
       newimage = level2image;
       newflag = 2;
      }
      else if(oldimage.indexOf(level3image)>0)
      {
       newimage =level3image;
       newflag = 3;
      }
     }
     //alert(strFormApproveID);
     document.getElementById("img"+strFormApproveID).src = "../image/"+newimage;
      
     var strData="<Data>";
     strData=strData+"<FormApproveID>"+strFormApproveID+"</FormApproveID>";
     strData=strData+"<NewMark>"+newflag+"</NewMark>";
     strData=strData+"</Data>";
     
     //var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
     //var xmlDoc=new ActiveXObject("Microsoft.XMLDom"); 
     var xmlhttp;
     var xmlDoc;
     
     try {
            // Internet Explorer   
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

        }
        catch (e) {
            // Firefox, Opera 8.0+, Safari   
            try {
                xmlhttp = new XMLHttpRequest();
            }
            catch (e) {  
            }
        }
     
     try
     {
         xmlDoc = new ActiveXObject("Microsoft.XMLDom");   
     }
     catch(e){
         try{
            xmlDoc = document.implementation.createDocument("", "", null);
          
                        Document.prototype.loadXML = function(sXml) {
                            var oParser = new DOMParser();
                            var _xmlDom = oParser.parseFromString(sXml, "text/xml");

                            while (this.firstChild) {
                                this.removeChild(this.firstChild);
                            }

                            for (var i = 0; i < _xmlDom.childNodes.length; i++) {
                                var oNewNode = this.importNode(_xmlDom.childNodes[i], true);
                                this.appendChild(oNewNode);
                            }
                        }
                        Element.prototype.__defineGetter__("text", function() { return this.textContent; });     
         }
         catch(e){ 
         }
     }
     
      xmlDoc.async = false;
      xmlDoc.loadXML(strData);
        
     xmlhttp.open("POST", "Module/SelectMark.aspx", false);
     xmlhttp.send(xmlDoc);
     

         </script>

    <img id="imgALI.FMAP.4009576" onclick="selectImageMark(this.id,0)" src="../image/RedMark.gif"
                                        style="border- 0px; cursor: pointer;" /><img id="imgarALI.FMAP.4009576" onclick="javascript:hideSelectMark();showSelectMark('imgALI.FMAP.4009576')"
                                            src="../image/arrow.gif" style="border- 0px; cursor: pointer;" />
                                   
                                    <div id='divMarkALI.FMAP.4009576' style='z-index: 20; left: 0px; visibility: hidden;
                                        position: absolute; top: 0px; 20px; height: 100px' class='DivMark' onmouseout="this.style.visibility='hidden';hidePopup();"
                                        onmouseover="this.style.visibility='visible'">
                                        <table cellspacing="0" cellpadding="0" width="20px" height="100px" border="0">
                                            <tr style="cursor: pointer">
                                                <td nowrap>
                                                    <img src="../image/RedMark.gif" id="imgredALI.FMAP.4009576" onclick="selectImageMark(this.id,1)">
                                                </td>
                                            </tr>
                                            <tr style="cursor: pointer">
                                                <td nowrap>
                                                    <img src="../image/YellowMark.gif" id="imgyelALI.FMAP.4009576" onclick="selectImageMark(this.id,1)">
                                                </td>
                                            </tr>
                                            <tr style="cursor: pointer">
                                                <td nowrap>
                                                    <img src="../image/GreenMark.gif" id="imggreALI.FMAP.4009576" onclick="selectImageMark(this.id,1)">
                                                </td>
                                            </tr>
                                            <tr style="cursor: pointer">
                                                <td nowrap>
                                                    <img src="../image/NoneMark.gif" id="imgnonALI.FMAP.4009576" onclick="selectImageMark(this.id,1)">
                                                </td>
                                            </tr>
                                        </table>
                                    </div>

    接收处理XML数据

    protected void Page_Load(object sender, EventArgs e)
            {
                if (!this.IsPostBack)
                {
                     XmlDocument xmldoc = new XmlDocument();
                     xmldoc.Load(Request.InputStream);
                     string xmlcontent = xmldoc.InnerXml;

                     #region xml格式
                     //var strData = "<Data>";
                     //strData = strData + "<FormApproveID>" + strFormApproveID + "</FormApproveID>";
                     //strData = strData + "<NewMark>" + newflag + "</NewMark>";
                     //strData = strData + "</Data>";
                     #endregion

                     string formApproveID = GetNodeValue(xmldoc, "Data/FormApproveID");
                     string newMark = GetNodeValue(xmldoc, "Data/NewMark");
                     if (!string.IsNullOrEmpty(formApproveID) && !string.IsNullOrEmpty(newMark))
                     {
                         BLL.BPMFormManager.UpdteFormMark(formApproveID, int.Parse(newMark),this.Passport);
                     }
                }
            }

            private static XmlNode GetNode(XmlDocument doc, string strXPath)
            {
                return doc.DocumentElement.SelectSingleNode(strXPath);
            }
            private static string GetNodeValue(XmlDocument doc, string strXPath)
            {
                XmlNode node = doc.SelectSingleNode(strXPath);
                if (node != null)
                {
                    return node.InnerText;
                }
                return String.Empty;
            }

  • 相关阅读:
    BZOJ 2006: [NOI2010]超级钢琴 [ST表+堆 | 主席树]
    CF 741D. Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths [dsu on tree 类似点分治]
    CF 716E. Digit Tree [点分治]
    CF 291E. Tree-String Problem [dfs kmp trie图优化]
    CF 208E. Blood Cousins [dsu on tree 倍增]
    CF 246E. Blood Cousins Return [dsu on tree STL]
    CF 570D. Tree Requests [dsu on tree]
    [dsu on tree]【学习笔记】
    测试markdown
    BZOJ 1969: [Ahoi2005]LANE 航线规划 [树链剖分 时间倒流]
  • 原文地址:https://www.cnblogs.com/huanghai223/p/2802716.html
Copyright © 2011-2022 走看看