<input class="form-control js-datepicker m-b-10" type="text" id="example-datepicker" name="example-datepicker" placeholder="yyyy-mm-dd" value="" data-date-format="yyyy-mm-dd" />
我有一个这样的Input日期选择框,怎么做成选择立刻执行 /index.php?date=日期
<input class="form-control js-datepicker m-b-10" type="text" id="example-datepicker" name="example-datepicker" placeholder="yyyy-mm-dd" value="" data-date-format="yyyy-mm-dd" />
我有一个这样的Input日期选择框,怎么做成选择立刻执行 /index.php?date=日期
<input class="form-control js-datepicker m-b-10" type="text" id="example-datepicker" name="example-datepicker" placeholder="yyyy-mm-dd" value="" data-date-format="yyyy-mm-dd" />
<script>
// 获取日期选择器元素
const datepicker = document.getElementById('example-datepicker');
// 监听日期选择器值的更改
datepicker.addEventListener('change', function() {
// 构造重定向URL
const url = '/index.php?date=' + datepicker.value;
// 重定向到URL
window.location.href = url;
});
</script>