[quote]
var xmlHttp;
var dataDiv;
var offsetEl;
//create the XMLHttpRequest object
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} else {
if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
if (!xmlHttp) {
alert("fail to create the XMLHttpRequest object");
}
}
//initialization the div object
function initVars() {
dataDiv = document.getElementById("popup");
dataDiv.style.visibility = "visible";
}
//get the element's value when the mouse over it
function getData(element) {
initVars();
createXMLHttpRequest();
offsetEl = element;
var url = "/PhoneTest/shoppingCart.do?method=getData&pid=" + escape(element.id);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = callBack;
xmlHttp.send(null);
}
function callBack() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
setData(xmlHttp.responseXML);
}
}
//clear the value in the div
function clearData() {
dataDiv.innerHTML = "";
dataDiv.style.width = 0;
dataDiv.style.height = 0;
dataDiv.innerText = "";
dataDiv.style.borderColor = "#FFFFFF";
//dataDiv.style.visibility = "hidden";
}
function hiddenDIV() {
dataDiv.style.visibility = "hidden";
}
//show the div
function showDIV() {
dataDiv.style.visibility = "visible";
}
//show the data on the div
function setData(xml) {
clearData();
pid = xml.getElementsByTagName("pid")[0].firstChild.data;
pinpai_id = xml.getElementsByTagName("pinpaiid")[0].firstChild.data;
var pinpai = xml.getElementsByTagName("pinpai")[0].firstChild.data;
var pattern = xml.getElementsByTagName("pattern")[0].firstChild.data;
var member_price = xml.getElementsByTagName("member_price")[0].firstChild.data;
var basicfunction = xml.getElementsByTagName("basicfunction")[0].firstChild.data;
dataDiv.innerHTML = "<font color=red>" + pinpai + pattern + "</font><br/>";
dataDiv.innerHTML += "<font color=red>\u4f1a\u5458\u4ef7:</font>" + member_price + "\u5143";
dataDiv.innerHTML += "<br/><font color=red>\u57fa\u672c\u529f\u80fd:</font>" + basicfunction;
dataDiv.innerHTML += "<br/><a href='/PhoneTest/eachPhone/eachPhone.jsp?pid=" + pid + "&pinpai_id=" + pinpai_id + "' style='color:red'>\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f>>></a>";
dataDiv.style.left = calculateLeft(offsetEl, "offsetLeft") - 200 + "px";
dataDiv.style.border = "blue 1px solid";
dataDiv.style.borderColor = "#111111";
dataDiv.style.background = "#FFFFFF";
dataDiv.style.top = calculateTop(offsetEl, "offsetTop") + "px";
dataDiv.style.width = "200px";
}
//return the mouseover element moving top
function calculateTop(ele, moveset) {
var offset = 0;
while (ele) {
offset += ele[moveset];
ele = ele.offsetParent;
}
return offset;
}
function calculateLeft(ele, moveset) {
var offset = 0;
while (ele) {
offset += ele[moveset];
ele = ele.offsetParent;
}
return offset;
}
[/quote]
var xmlHttp;
var dataDiv;
var offsetEl;
//create the XMLHttpRequest object
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} else {
if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
if (!xmlHttp) {
alert("fail to create the XMLHttpRequest object");
}
}
//initialization the div object
function initVars() {
dataDiv = document.getElementById("popup");
dataDiv.style.visibility = "visible";
}
//get the element's value when the mouse over it
function getData(element) {
initVars();
createXMLHttpRequest();
offsetEl = element;
var url = "/PhoneTest/shoppingCart.do?method=getData&pid=" + escape(element.id);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = callBack;
xmlHttp.send(null);
}
function callBack() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
setData(xmlHttp.responseXML);
}
}
//clear the value in the div
function clearData() {
dataDiv.innerHTML = "";
dataDiv.style.width = 0;
dataDiv.style.height = 0;
dataDiv.innerText = "";
dataDiv.style.borderColor = "#FFFFFF";
//dataDiv.style.visibility = "hidden";
}
function hiddenDIV() {
dataDiv.style.visibility = "hidden";
}
//show the div
function showDIV() {
dataDiv.style.visibility = "visible";
}
//show the data on the div
function setData(xml) {
clearData();
pid = xml.getElementsByTagName("pid")[0].firstChild.data;
pinpai_id = xml.getElementsByTagName("pinpaiid")[0].firstChild.data;
var pinpai = xml.getElementsByTagName("pinpai")[0].firstChild.data;
var pattern = xml.getElementsByTagName("pattern")[0].firstChild.data;
var member_price = xml.getElementsByTagName("member_price")[0].firstChild.data;
var basicfunction = xml.getElementsByTagName("basicfunction")[0].firstChild.data;
dataDiv.innerHTML = "<font color=red>" + pinpai + pattern + "</font><br/>";
dataDiv.innerHTML += "<font color=red>\u4f1a\u5458\u4ef7:</font>" + member_price + "\u5143";
dataDiv.innerHTML += "<br/><font color=red>\u57fa\u672c\u529f\u80fd:</font>" + basicfunction;
dataDiv.innerHTML += "<br/><a href='/PhoneTest/eachPhone/eachPhone.jsp?pid=" + pid + "&pinpai_id=" + pinpai_id + "' style='color:red'>\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f>>></a>";
dataDiv.style.left = calculateLeft(offsetEl, "offsetLeft") - 200 + "px";
dataDiv.style.border = "blue 1px solid";
dataDiv.style.borderColor = "#111111";
dataDiv.style.background = "#FFFFFF";
dataDiv.style.top = calculateTop(offsetEl, "offsetTop") + "px";
dataDiv.style.width = "200px";
}
//return the mouseover element moving top
function calculateTop(ele, moveset) {
var offset = 0;
while (ele) {
offset += ele[moveset];
ele = ele.offsetParent;
}
return offset;
}
function calculateLeft(ele, moveset) {
var offset = 0;
while (ele) {
offset += ele[moveset];
ele = ele.offsetParent;
}
return offset;
}
[/quote]