我正在通过下拉框中的 topicList 数组从 Controller 获取 TopicName 并将其显示到下拉列表中。我想要做的是在发送回所选下拉列表的值时,我想通过 javascript 函数将 topicId(也存储在 topicList 数组中)发送到我的 Controller 。 这是我的 Html 代码。 选择主题:
<td>
<select name="Topic" id="Topic" class="myDropDown">
<option selected="selected" value="-1">-- Select Topic --</option>
<c:forEach var="item" items="${topicList}">
<option >${item.topicName} </option>
//Here I want to send the value of item.topicId`enter code here`
</c:forEach>
</select>
</td>
这是我通过即时发送我的值的 JavaScript 函数 函数 doAddTopic(){
var subName=jq("#Topic option:selected").val();
// alert(name);aaaaaaaaaaaaaaaaaaaaaaaaaaaaa
var url = "/xyz/abc/"+subName+"/";
jq.post(url, function(data)
}
我想要的是在选择 item.topicName 时发送 item.topicId 的值。我该怎么做
最佳答案
也许你应该这样尝试,
<c:forEach var="item" items="${topicList}">
<option value="${item.topicId}">${item.topicName} </option>
//Here I want to send the value of item.topicId`enter code here`
</c:forEach>
在选项内赋值 value="${item.topicId}"
关于javascript - 将所选下拉列表的动态值发送到 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17759339/