这类似于另一个问题,但是表单不会提交。
基本上我在这里尝试实现的是,一旦用户单击“提交”btn,btn 将被禁用,直到页面被重定向,以避免用户多次单击提交 btn。
用户被重定向到的页面不会显示表单中的信息。在我介绍禁用和启用功能之前,这确实可以正常工作。
提供的代码确实禁用了 btn,甚至将文本更改为“提交”,但不会重定向到摘要页面,即使当我通过选项卡导航到摘要页面时,信息也不存在。任何帮助都非常感谢...
表格代码…………
<div class="portlet-body form">
<!-- BEGIN FORM-->
@using (Html.BeginForm("RequestAppointment", "Appointment", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", id= "apptReqForm" }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(false, string.Empty, new { @class = "alert alert-error" })
<div class="control-group">
<label class="control-label">Healthcare Professional</label>
<div class="controls">
@Html.DropDownListFor(m => m.RequestedUserID, Model.Hcps, string.Empty)
</div>
</div>
<div class="control-group">
<label class="control-label">@Html.LabelFor(m => m.RequestedDateTime)</label>
<div class="controls">
<div class="input-append" id="ui_date_picker_trigger">
@Html.EditorFor(m => m.RequestedDateTime)
<span class="add-on"><i class="icon-calendar"></i></span>
</div>
</div>
</div>
<div class="control-group">
<label class="control-label">@Html.LabelFor(m => m.SelectedTime, "Time")</label>
<div class="controls">
<div id="timeSlotID" data-request-url="@Url.Action("LoadTimeslots")">
<select id="SelectedTime" name="SelectedTime"></select>
</div>
</div>
</div>
<div class="control-group">
<label class="control-label">@Html.LabelFor(m => m.AdditionalNotes)</label>
<div class="controls">
@Html.TextAreaFor(m => m.AdditionalNotes, new { @class = "span6 m-wrap", rows = 3 })
<span class="help-block m-wrap">In the event the selected time you have chosen is not available, please state above if your booking time is flexible.</span>
</div>
</div>
<div class="form-actions">
<button type="submit" class= "btn blue" id="submit" onclick="disable();"><i class="icon-ok"></i>Submit</button>
<button type="button" class="btn" onclick="location.href='RequestedAppointments'">Cancel</button>
</div>
}
</div>
<div class="form-actions">
<button type="submit" class= "btn blue" id="submit" onclick="disable();"><i class="icon-ok"></i>Submit</button>
<script>
function disable() {
x = document.getElementById("submit");
x.disabled = true;
x.textContent = "Submitting...";
document.getElementById("apptReqForm").submit();
setTimeout(enable, 5000);
}
function enable() {
x = document.getElementById("submit");
x.disabled = false;
x.textContent = " Submit";
}
</script>