I have a select option with onchange
function that can change the value in other input whenever I click the option.
However it is not working on multiple select which just only show the first select option value only when select many of the option.
HTML select option code
<select class="form-control" onchange="selectFunction(event)"
name="pay_course[]" required="" multiple>
<option data-typeid="1111" value="courseId1">courseName1</option>
<option data-typeid="2222" value="courseId2">courseName2</option>
</select>
Input to be display the total
<input type="number" value="" id="money" class="form-control">
Function script
<script>
function selectFunction(e) {
var type_id = $('select option:selected').attr('data-typeid'); //to get value
document.getElementById("money").value =type_id;
}
</script>