提前抱歉,开发代码和网络访问位于两个单独的平台上,因此我无法复制和粘贴。
在我的jsp中,如果有一个列表定义如下:
<form:form id=""fm-form commandname="command" action="$actionURL" onsubmit="return false;">
// what does this commandName="command" do? I see it in several places in the code
// and it all has to do with dropdown lists.
.
.
.
.
.
<form:select id="fm-explosives2" path="fm-explosives2" items="${command.explosiveList}" onchange="populateDensity(); populatetntEquiv()";/>
然后我调用.js文件中的makeCaluculations()...
function makeCalculations(){
...
var explosiveNames = new array();
.
.
.
var explosiveList = DWRUtil.getValue("fm-explosive2");
// this should have all the names from the dropdown list - or am I wrong?
// then I try to populate the array to be used later...
for (var i=0; i < explosiveList.length; i++){
var explosive = explosiveList[i];
alert("explosive name is: " + explosive.explosives); // all NULL values!!! Why? Help!
explosiveNames.push(explosive.explosives);
more code .....
}
}
问题:这个commandName =“command”(在.jsp源代码中)是做什么的?我在代码中的几个地方看到它 这一切都与下拉列表有关。任何人吗?
答案 0 :(得分:0)
根据您的评论澄清。你的功能看起来像......
function makeCalculations(){
var explosiveNames = [];
var explosives = DWRUtil.getValue("fm-explosive2");
// this should have all the names from the dropdown list - or am I wrong?
// then I try to populate the array to be used later...
for (var i=0; i < explosives.length; i++){
var explosivenames = explosiveList[i];
alert("explosive name is: " + explosives[i].explosives);
explosiveNames.push(explosives[i].explosives);
}
答案 1 :(得分:0)
explosive
未在您的整个代码中定义。explosive.explosives
,它应该是explosiveList[i].explosives
,其中explosives
可以是explosiveList[i]
所以,基本上用
explosive.explosives
代替 在您的代码中explosiveList[i].explosives
,它应该可以正常工作。