我得到了以下代码:
<form method="post" accept-charset="UTF-8" action="showPartners.action?" id="_form" onsubmit="return selCheck();">
<div style="float: left; width: 350px;">
<span class="text_vert"> Select Country : </span>
<s:select style="width:200px;" onchange="loadBusinessList();"
headerKey="-1" headerValue="Country Select" list="couList"
listKey="idCountry" listValue="label" id="countryId"
name="countryId">
</s:select>
</div>
<a href='addPartner.action?height=550&width=850&id=<s:property value="countryId"/>'" >Insert</a>
</form>
我需要做的是将国家/地区 ID 传递给 a href 标记中的链接,但我得到的是 ID=0。
如果有任何帮助,我将不胜感激。
最佳答案
最简单的解决方案是使用 JavaScript,如下所示:
<s:select style="width:200px;" onchange="loadBusinessList();document.getElementById('anchor_id').href=document.getElementById('anchor_id').href.replace(/&id=(?:$|\d+)/, '&id=' + this.value)" ...
还有:
<a id="anchor_id" href='addPartner.action?height=550&width=850&id=0'" >Insert</a>
请注意:代码假定您的国家/地区 ID 是整数。
关于java - 如何将国家/地区 ID 传递给 <a href> 标记?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22807045/