【发布时间】:2020-11-21 02:44:10
【问题描述】:
我正在从 java servlet 向 jsp 发送一个树形图。我可以使用树图键作为 jsp 页面内的下拉列表。当用户选择国家名称时,我的地图包含国家名称作为键,大写作为值我只需要在文本框中显示国家资本。我需要在提交表单后在 java 页面中选择键值(国家名称)(我知道要做这)。当我从 java 脚本中读取地图时,它被视为字符串/[对象对象]。我如何在这里使用 map.get(key)。提前致谢
function fillText(obj)
{
var key= obj.options[obj.selectedIndex].value;
var map = new Map('<%=request.getAttribute("countrylist")%>');
var contract = "${countrylist}";
}
<label for="Select The Switch">Select The Switch:</label>
<select name="country" id="countrycode" onchange="fillText(this)" required>
<option value= "" >Please select the switch</option>
<c:forEach items="${countrylist}" var="countrylist">
<option value=${countrylist.key}>${countrylist.key}</option>
</c:forEach>
</select>`)
Country capital:<input type="text" id="pass" readonly >
【问题讨论】:
-
你为什么混合
jsp和js?使用 ajax 将下拉列表的值发送到后端,然后获取您需要的值。
标签: javascript java jquery