我写了以下 scr,但我的表单字段仍然为空。
function callme(e) {
let today = new Date();
document.getElementById('dtCikisTarih').value = today;
}
我的表单字段有一个具体定义为
<asp:Button ID="btnAktar" runat="server" Text="Aktar" CommandName="AktarRow" class = "inp" OnClientClick="return callme(this)" />
<iskurDateTimeBoxes:IskurDateBox ID="dtCikisTarih" runat="server" clientidmode="static"/>
在 javascript 中设置日期字段 你的代码应该是这样的
let today = new Date();
// Format the date as needed (YYYY-MM-DD)
let formattedDate = today.toISOString().substr(0, 10);
// Set the value of the input field
document.getElementById('dtCikisTarih').value = formattedDate;
直接将日期值设置为 Date 对象的问题。您需要将日期格式化为输入字段所需的适当格式的字符串