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