var XMLHttpReq = false; var res; var div_Input; // ����XMLHttpRequest���� function createXMLHttpRequest() { if (window.XMLHttpRequest) { XMLHttpReq = new XMLHttpRequest(); } else if (window.ActiveXObject) { try { XMLHttpReq = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { } } } } // ���������� function sendRequest() { createXMLHttpRequest(); var xml = getInputTOXml(); XMLHttpReq.open("POST", "/GDZJ/XmlStoreDataServlet", true); XMLHttpReq.onreadystatechange = processResponse; XMLHttpReq.setRequestHeader("Content-Type", "application/x-www-form- urlencoded"); XMLHttpReq.send(xml); } // ���?����Ϣ���� function processResponse() { if (XMLHttpReq.readyState == 4) { if (XMLHttpReq.status == 200) { displayHot(); } else { window.alert("���������ҳ�����쳣��"); } } } // �������ص�xml��Ϣ function displayHot() { var objectID = XMLHttpReq.responseXML.getElementsByTagName("objectID")[0].firstChild.nodeValue; var responseText = XMLHttpReq.responseXML .getElementsByTagName("responseText")[0].firstChild.nodeValue; res = document.getElementById("responseText"); document.all.objectID.value = objectID; res.innerHTML = responseText; dispDiv(); setTimeout("deletDispDiv()", 3000); } // ��ʾ������Ϣ function dispDiv() { var savebutton = document.all.btmbox; div_Input = document.getElementById("div_Input"); div_Input.style.display = "block"; div_Input.style.left = savebutton.offsetLeft + 520; div_Input.style.top = savebutton.offsetTop - 30; } // ɾ��ص���ʾ��Ϣ function deletDispDiv() { div_Input.style.display = "none"; } function createXMLDOM() { var arrSignatures = ["MSXML2.DOMDocument.5.0", "MSXML2.DOMDocument.4.0", "MSXML2.DOMDocument.3.0", "MSXML2.DOMDocument", "Microsoft.XmlDom"]; for (var i = 0; i < arrSignatures.length; i++) { try { var oXmlDom = new ActiveXObject(arrSignatures[i]); return oXmlDom; } catch (oError) { // ignore } } throw new Error("���ϵͳû�а�װMSXML"); } /** * ����Ҫ�ύ����̨�������ɵ�XML */ function getInputTOXml() { var doc = createXMLDOM(); // �����ļ�ͷ // var p = doc.createProcessingInstruction("xml","version='1.0' // encoding='gb2312'"); // doc.appendChild(p); doc.createElement("students"); var root = doc.createNode(1, "students", ""); // �����ӽӵ� var n = doc.createNode(1, "ttyp", ""); var o; var newObject = document.getElementsByTagName("input"); var checkLen = newObject.length var i = 0; while (i < checkLen) { var oneItem = newObject.item(i); var objName = oneItem.name; var objValue = oneItem.value; if (objName != null && objName != "") { if (oneItem.type == "radio") { objValue = getRadioCheckboxValue(objName); } // ������ӵ� alert(eval("document.form1." + objName)) o = doc.createElement(objName); o.text = objValue; // ָ�����ı� // �����ӵ� n.appendChild(o); // ����ӽӵ� root.appendChild(n); } i = i + 1; } var newObject = document.getElementsByTagName("select"); var checkLen = newObject.length var i = 0; while (i < checkLen) { var oneItem = newObject.item(i); var objName = oneItem.name; var objValue = oneItem.value; if (objName != null && objName != "") { // ������ӵ� o = doc.createElement(objName); o.text = objValue; // ָ�����ı� // �����ӵ� n.appendChild(o); // ����ӽӵ� root.appendChild(n); } i = i + 1; } var newObject = document.getElementsByTagName("textarea"); var checkLen = newObject.length var i = 0; while (i < checkLen) { var oneItem = newObject.item(i); var objName = oneItem.name; var objValue = oneItem.value; if (objName != null && objName != "") { // ������ӵ� o = doc.createElement(objName); o.text = objValue; // ָ�����ı� // �����ӵ� n.appendChild(o); // ����ӽӵ� root.appendChild(n); } i = i + 1; } // ���ƽӵ� var m = n.cloneNode(true); root.appendChild(m); // ɾ��ӵ� root.removeChild(root.childNodes(0)); // ��Ӹ�ӵ� doc.appendChild(root); return "" + n.ownerDocument.xml; } function getRadioCheckboxValue(aControlName) { var aObj = document.getElementsByName(aControlName); var count = aObj.length; for (i = 0; i < count; i++) { if (aObj[i].checked == true) { return aObj[i].value; } } return ""; }