次の「form.jsp」プログラムがあります。ドロップダウンリストを生成します。リストの下には、選択したアイテムのdisplay_nameを表示するテキストエリアがあります。ユーザーがアイテムを選択すると、選択したアイテムIDがテキストエリアに表示されます。私のコードから DB を呼び出し、javascript で display_name を取得して、結果の display_name が textarea に表示されるようにする方法は?
<%@ taglib prefix="s" uri="/struts-tags"%>
<script type="text/javascript">
function callme(Display_Name)
{
alert('callme : Display_Name = '+Display_Name);
var v=document.getElementById('hiddenValue').value;
alert('hiddenValue : v = '+v);
document.getElementById('defaultDisplayName').value=Display_Name;
}
</script>
<s:hidden id="pricelist.id" name="pricelist.id" value="%{pricelist.id}"/>
<div class="dialog">
<table>
<tbody>
<s:if test="%{enableProductList}">
<tr class="prop">
<td valign="top" class="name required"><label for="description">Product:</label></td>
<td valign="top">
<s:select id="productPrice.product"
name="productPrice.product"
headerKey="0"
headerValue="-- Select Product --"
list="products"
listKey="id"
listValue="name"
value="productPrice.product.id"
theme="simple"
onchange="callme(value)"
/>
<s:hidden id="hiddenValue" name="hiddenValue" value="123"/>
</td>
</tr>
</s:if>
<tr class="prop">
<td valign="top" class="name"><label for="description">Default Display Name:</label></td>
<td valign="top"><s:textarea id="defaultDisplayName" name="defaultDisplayName" theme="simple" readonly="true"/></td>
</tr>
詳細については、添付の画像を参照してください。DB では、製品テーブルに製品 ID と display_name があります。ID はわかっています。Java を使用して display_name を取得し、それを jsp にプラグインする方法は?