我有一个创建数据行的迭代器。一列包含指向操作的链接。另一列是选择框。我不能在我的生活中获得在选择框中选择的值,以便在单击链接时作为参数传递。我已经尝试过javascript并且我在函数内部获得了正确的值,但是在点击链接时它并没有作为参数传递。我错过了一些东西,但我无法弄清楚是什么。
<s:iterator var="permit" value="permitsList" status="status" >
<tr class="<s:if test="#status.even">even</s:if><s:else>odd</s:else>">
<td style="text-align: center">
<s:url var="dataEntryURL" action="processPermitSelectedSuccess">
<s:param name="permitInfo.mepdesNumber" value="permitsList[#status.index].mepdesNumber" />
<s:param name="permitInfo.facilityName" value="permitsList[#status.index].permitHistoryList[0].facilityName" />
NOTE: If permitInfo.outfallNumber is set to a value; the parameter and value are tacked onto the URL. Using the following code, there is no parameter or value for permitList.outfallNumber included on the URL.
<s:param name="permitInfo.outfallNumber" value="permitsList[%{#status.index}].selectedOutfall}" />
</s:url>
<s:a href="%{dataEntryURL}">
<s:property value="permitsList[#status.index].mepdesNumber" />
</s:a>
</td>
<td style="text-align: left">
<s:property value="permitsList[#status.index].permitHistoryList[0].facilityName" />
</td>
<td style="text-align: center; white-space: nowrap" >
<s:if test="permitsList[#status.index].outfallsList.size() > 1">
<s:if test="permitsList[#status.index].selectedOutfall == null" >
<s:set var="permitsList[#status.index].selectedOutfall" value="permitsList[#status.index].defaultOutfall" />
</s:if>
<s:select theme="simple"
name="permitsList[#status.index]selectedOutfall"
id="permitsList[#status.index]selectedOutfall"
list="permitsList[#status.index].outfallsList"
listKey="outfallsPK.outfallNumber"
listValue="outfallsPK.outfallNumber"
value="permitsList[#status.index].selectedOutfall"
onchange="javascript: setOutfall(this.value)">
</s:select>
</s:if>
<s:else>
<s:property value="permitsList[#status.index].defaultOutfall" />
</s:else>
</td>
</tr>
</s:iterator>
我使用的javascript:
function setOutfall(selectedValue)
{
// Using setTimeout() in this way forces IE to use a separate thread
// for the .focus() function instead of processing at the same time
// as it's own browser behaviour.
alert("inside setOutfall() - selectedValue: " + selectedValue);
setTimeout
(function()
{
try
{
document.getElementsByName('permitsList[#status.index].selectedOutfall').value = selectedValue;
alert("correctValue: " + document.getElementsByName('permitsList[#status.index].selectedOutfall').value);
}
catch(err)
{
txt="There was an error on this page.\n\n";
txt+="Error description: " + err.message + "\n\n";
txt+="Click OK to continue.\n\n";
alert(txt);
}
}
, 50);
}
请帮忙!感谢