0
我想从Javascript隐藏字段插入数据到XML但是,只有'空'出来。我已经声明了这些变量,但它似乎无法捕获隐藏的字段。我的智慧结束了,我希望我的问题能够得到解决。如何通过JSP代码将隐藏字段(Javascript)插入到XML中?
**<<-----I use session to pass the value to the XML page----->>**
<%
String X = (String)session.getAttribute("X");
String Y = (String)session.getAttribute("Y");
String W = (String)session.getAttribute("W");
String H = (String)session.getAttribute("H");
session.setAttribute("X",X);
session.setAttribute("Y",Y);
session.setAttribute("W",W);
session.setAttribute("H",H);
%>
**<<------Snippet of Javascript codes------->>**
function moveIt(){
if (!moveEnabled||!MovableItem) return;
// display info during testing
X = MovableItem.offsetLeft;
Y = MovableItem.offsetTop;
W = MovableItem.offsetWidth;
H = MovableItem.offsetHeight;
==Some codes here==
document.getElementById('X').value = X;
document.getElementById('Y').value = Y;
document.getElementById('W').value = W;
document.getElementById('H').value = H;
}
**<<-----JSP codes that I need to pass the values onto an XML----->>**
<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。我试过了,但是它出现为'空'。有没有人可以帮我解决这个问题?谢谢一堆!
是的,对不起,我其实已经解决了这个问题。现在我面临将多个记录插入XML文件的另一个问题。有任何想法吗? – user1570480 2012-08-15 01:20:00