我想從此欄位中選擇 startDate:@Html.EditorFor(model => model.TimePeriod.StartDate, new { htmlAttributes = new { @class = "form-control datepicker", @id="StartDate",@onchange= "addDates()" } }) @Html.ValidationMessageFor(model => model.TimePeriod.StartDate, "", new { @class = "text-danger" })
在這里我想在這里自動填充開始日期
<td>
@Html.EditorFor(model => model.DailyRegister.Date, new { htmlAttributes = new { @class = "form-control", required = "required", @id = "date1" } })
@Html.ValidationMessageFor(model => model.DailyRegister.Date, "", new { @class = "text-danger" })
<script>
function addDates() {
document.getElementById("date1").value = document.getElementById("StartDate");
}
</script>
</td>
運行上面的代碼給出了這個結果
uj5u.com熱心網友回復:
這可能是一個愚蠢的問題,但是您是否嘗試過獲取開始日期欄位的值?
document.getElementById("date1").value = document.getElementById("StartDate").value;
根據您呼叫addDates()函式的時間,您可能還需要一個事件偵聽器。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/407641.html
標籤:
上一篇:方法未系結到事件處理程式
下一篇:無法將型別System.Collections.generic隱式轉換為<ProjectNamespace.List>
