【发布时间】:2021-12-15 03:26:47
【问题描述】:
我有一个这样的下拉列表:
<select id="itemsList" onchange="gettingList()">
<option>Please select the option</option>
<option value="50">Soap</option>
<option value="100">Sugar</option>
<option value="290">Oil</option>
</select>
<br><br>
我必须在下面的输入标签中获取上面列表的值。
<input type="text" id="price">
为此,我正在使用这个脚本。
<script>
function gettingList() {
var selectItem = document.getElementById('itemsList').value;
var displayPrice = selectItem.options[selectItem.selectedIndex].text;
document.getElementById('price').value = displayPrice;
}
</script>
我该如何解决这个问题?
【问题讨论】:
标签: javascript html css arrays html5-canvas