下拉選單(drop-down menu)取值

使用onchangedocument.getElementById("xxx").value進行下拉選單(drop-down menu)取值。

HTML:

<div id="item">
	<label style="font-weight:bold;">下拉選單:</label>
	<select id="tool_type" name="tool_type" style="cursor:pointer;" class="selectpicker ml-1 mb-2" data-width="150px" onchange="select()">
		<option value="0">請選擇</option>
		<option value="1">選項1</option>
		<option value="2">選項2</option>
		<option value="3">選項3</option>
		<option value="4">選項4</option>
	</select>

</div>

JavaScript:

function select(){
	var selected = document.getElementById("tool_type").value;
	console.log(selected);
}