表单开始:
<% using (Html.BeginForm("Index", "recordssbook", FormMethod.Post, new { id = "SubmitForm" }))
{ %>
我想要验证的提交按钮(同一表单中有其他提交按钮):
<div><input type="submit" value="Delete Selected" id ="DeleteButton" name="DeleteButton" onclick="deleteRecordsDialog();"/></div>
js中我的确认对话框中的按钮会自动返回false:
function deleteRecordsDialog() {
var returnThis;
var numRecords = selectedRecordsArr.length;
document.getElementById("popupContainer");
var html = ""
html= html + '<table>';
html= html + '<tr>';
html= html + '<td class="warning-icon-cell"></td>';
html= html + '<td style="padding-left: 5px;">';
if (numAddresses == 1) {
html = html + '<p>You have chosen to delete a record.</p>';
}
else {
html = html + '<p>You have chosen to delete ' + numRecords + ' records.</p>';
}
html= html + '<p>Are you sure you wish to proceed?</p>';
html= html + '</td>';
html= html + '</tr>';
html = html + '</table>';
if (numAddresses == 1) {
html = html + '<div><input type="button" value="Yes, Delete Contact" style="width: 160px; onclick="document.DSubmitForm.HDeleteButton.submit(); CloseDialog();"/> <input type="button" value="Cancel" onclick="CloseDialog();"/></div>';
}
else {
html = html + '<div><input type="submit" value="Yes, Delete Contact(s)" style="width: 160px; onclick="document.DSubmitForm.HDeleteButton.submit(); CloseDialog();"/> <input type="button" value="Cancel" onclick="CloseDialog();"/></div>';
}
html = html + '</div>';
html = html + '</div>';
html = html + '</div>';
html = html + '</div>';
OpenDialog(html, 350, 180, false, "Delete Contact")
return false;
}
我的问题:
如果有人可以帮我解决这个问题,我会非常感激!
谢谢!
修改 所以html是一个带有按钮的记录列表,可以根据字母查询,添加记录,删除记录和编辑记录。所有这些按钮都是相同形式的提交按钮。
<td><input type="submit" value="ABC" name="SubmitButton"/></td>
<td><input type="submit" value="DEF" name="SubmitButton" /></td>
<td><input type="submit" value="GHI" name="SubmitButton" /></td>
<td><input type="submit" value="JKL" name="SubmitButton"/></td>
<td><input type="submit" value="MNO" name="SubmitButton"/></td>
<td><input type="submit" value="PQRS" name="SubmitButton" /></td>
<td><input type="submit" value="TUV" name="SubmitButton"/></td>
<td><input type="submit" value="WXYZ" name="SubmitButton" /></td>
<div><input type="button" value="Add Contact" id="addAddress" onclick="AddAddresDialog()" /></div>
<div><input type="button" value="View & Edit Selected" id="EditButton" name="EditButton" onclick="updateAddressDialog()"/></div>
<div><input type="submit" value="Delete Selected" id ="DeleteButton" name="SubmitButton" /></div>
我只想将确认对话框添加到被点击的删除按钮。我想使用自定义对话框窗口来确认它,该窗口是站点主机上的一个div,它通过放置在覆盖整个屏幕(在deleteRecordsDialog()中创建的掩码的顶部)弹出。
我想要做的是将删除任务的提交按钮(id =“DeleteButton)更改为常规按钮,该按钮只打开deleteRecordsDialog()创建的对话框,而不是现在的表单提交。”是的,删除联系人“自定义确认”对话框中的“按钮”应该承担提交表单的任务,其值为“删除所选项”,就像提交按钮现在一样。
答案 0 :(得分:1)
如果没有你的HTML,很难真正理解你想要做什么。但是,您可以尝试以下方法:
<强> HTML 强>:
<div>
<input type="submit" value="Delete Selected" id ="DeleteButton" name="DeleteButton" onclick="deleteRecordsDialog();"/>
<input type="button" id ="DeleteButtonSubmit" name="DeleteButtonSubmit" style="display:none;" />
</div>
<强> Javscript 强>:
为模态创建按钮:
html = html + '<div><input type="button" value="Yes, Delete Contact(s)" style="width: 160px; onclick="deleteContact();"/> <input type="button" value="Cancel" onclick="CloseDialog();"/></div>';
发布删除确认的功能:
function deleteContact()
{
document.getElementById('DeleteButtonSubmit').click();
}
此功能将点击用户最初点击按钮下方的隐藏按钮。如果您正确设置此按钮,表单应提交您需要的所有信息。