0
在下面的代碼中,我試圖在java方法option.value = <% ppList.get(i).getId(); %>
中使用var i
,但它對我來說工作不是很好。如何在javascript中獲取int變量以輸入java方法
這裏是完整的js函數:
function receiveAnswer(response) {
var aSeats = document.getElementById("aSeats");
while (aSeats.childNodes.length > 0) { // clear it out
aSeats.removeChild(aSeats.childNodes[0]);
}
<% List<Physical_Package> ppList = (List<Physical_Package>) session.getAttribute("currentPack"); %>
for (var i = 0; i < response.aSeats.length; i++) { // add the items back in
var option = aSeats.appendChild(document.createElement("option"));
option.setAttribute("type", "hidden");
option.setAttribute("name", "id");
option.setAttribute("value", "")
option.appendChild(document.createTextNode(response.aSeats[i]));
option.value = <% ppList.get(i).getId(); %>
}
}