In the drop-down list, select the date:
<option value="1">31.05.2018 0:00:00</option> I write to js:
var date = document.getElementById('AttendDate'); As a result, I get the value value equal to 1. How to get the date ???
31.05.2018 0:00:00 I wr...">
In the drop-down list, select the date:
<option value="1">31.05.2018 0:00:00</option> I write to js:
var date = document.getElementById('AttendDate'); As a result, I get the value value equal to 1. How to get the date ???
var date = document.querySelector('option:checked'); console.log(date.text); <select id="AttendDate"> <option value="1">31.05.2018 0:00:00</option> </select> As an option, use the "onChange" attribute and pass this to it.
var getSelect = function(sel) { var date = sel.options[sel.selectedIndex].text; console.log(date); } <select id="AttendDate" onChange="getSelect(this)"> <option selected>Выберите значение</option> <option value="1">31.05.2018 0:00:00</option> <option value="2">31.05.2018 10:00:00</option> </select> Source: https://ru.stackoverflow.com/questions/833188/
All Articles