我需要在 XML 中插入多个隐藏字段(数据)。目前,我一次只能插入一个数据。假设我有一些“图块”(包含多个坐标)要插入到 XML 中。所以,到目前为止,我一次只能在 XML 中插入一个“平铺”(数据)。
<<==Javascript code==>>
function moveIt(){
if (!moveEnabled||!MovableItem) return;
// display info during testing
X = MovableItem.offsetLeft;
Y = MovableItem.offsetTop;
W = MovableItem.offsetWidth;
H = MovableItem.offsetHeight;
document.getElementById('X').value = X;
document.getElementById('Y').value = Y;
document.getElementById('W').value = W;
document.getElementById('H').value = H;
document.form1.elements['X'].value;
document.form1.elements['Y'].value;
document.form1.elements['W'].value;
document.form1.elements['H'].value;
}
<<==JSP codes==>>
<form name='form1' action='UpdateXML.jsp' method='post'>
<input type='hidden' name=source value="<%=src%>" />
<input type='hidden' id="X" name="X" value="<%=X%>"/>
<input type='hidden' id="Y" name="Y" value="<%=Y%>"/>
<input type='hidden' id="W" name="W" value="<%=W%>"/>
<input type='hidden' id="H" name="H" value="<%=H%>"/>
<button type="button" onclick="window.location.href='editcompany.jsp'">Back!</button>
<button type="submit">Insert Into XML!</button>
</form>
<<==XML==>>
<%
try {
String X = request.getParameter("X");
String Y = request.getParameter("Y");
String W = request.getParameter("W");
String H = request.getParameter("H");
pw.println ( "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" );
pw.println ( "<TemplateEditor>");
pw.println ( "\t<Logo>");
pw.print ( "\t\t<X_Coord>"); pw.print (X); pw.println ( "</X_Coord>");
pw.print ( "\t\t<Y_Coord>"); pw.print (Y); pw.println ( "</Y_Coord>");
pw.print ( "\t\t<Width>"); pw.print (W); pw.println ( "</Width>");
pw.print ( "\t\t<Height>"); pw.print (H); pw.println ( "</Height>");
pw.println ( "\t</Logo>");
pw.println ( "</TemplateEditor>");
pw.flush();
pw.close();
br.close();
fw.close();
} catch (Exception e) {}
%>
希望有好心人能帮帮我!我真的很需要帮助。非常感谢
编辑:
函数 $(v){return document.getElementById(v)}
函数 startMove(e){
if (!MovableItem){return;}
canvas=isIE ? "BODY" : "HTML";
activeItem=isIE ? event.srcElement : e.target;
offsetx=isIE ? event.clientX : e.clientX;
offsety=isIE ? event.clientY : e.clientY;
lastX=parseInt(MovableItem.style.left);
lastY=parseInt(MovableItem.style.top);
lastW=parseInt(MovableItem.style.width);
lastH=parseInt(MovableItem.style.height);
if (offsetx+scrollAmt[0]>=(MovableItem.parentNode.offsetLeft+parseInt(MovableItem.style.left)+(MovableItem.offsetWidth*.98))|| offsety+scrollAmt[1]>=(MovableItem.parentNode.offsetTop+parseInt(MovableItem.style.top)+(MovableItem.offsetHeight*.98)) ){edge=true; MovableItem.style.cursor="se-resize"} else{edge=false;MovableItem.style.cursor="move"}
moveEnabled=true;
document.onmousemove=moveIt;
}
这有帮助吗?谢谢