จะแสดงวันที่มาจาก jQuery เพื่อแสดงวันที่ปัจจุบันได้อย่างไร ฉันมีรายการแบบเลื่อนลงและป้อนข้อมูลด้วย datepicker
ตอนนี้สิ่งที่ฉันทำคือ เมื่อผู้ใช้เลือกปี 2019-2020
จากเมนูแบบเลื่อนลง ฉันกำลังแสดงวันที่ในช่องป้อนข้อมูล 31/03/2020
หากเลือก 2020-2021
ก็จะแสดง 31/03/2021
ไปเรื่อยๆ
ฉันหมายถึงวันที่และเดือนได้รับการแก้ไขเพียงเปลี่ยนปีเท่านั้น
I am getting my output in the input field but when I click on the input field then it's showing the current date. I need whatever the date comes from the jquery that date auto selected.
$("#year").change(function() {
var dropdownDuration = this.value;
var items = dropdownDuration.split('-');
//alert("31/03/"+items[1]);
$("#yearDate").val("31/03/" + items[1]);
});
$("#yearDate").datepicker();
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css">
<select class="form-control" name="year" id="year">
<option value="" disabled selected>Year</option>
<option value="2019-2020">2019-2020 </option>
<option value="2020-2021">2020-2021 </option>
<option value="2021-2022">2021-2022 </option>
</select>
<input type="text" name="enddate" class="form-control datepicker" id="yearDate">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.js"></script>