表格开始:
<% 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>
我只想将确认对话框添加到正在单击的删除按钮。我想使用自定义对话框窗口进行确认,该窗口是site master上的一个div,通过放置在覆盖在deleteRecordsDialog()中创建的整个屏幕的遮罩顶部而显示为弹出窗口。
我要做的是将删除任务的提交按钮(id=“DeleteButton”)更改为常规按钮,该按钮只打开由deleteRecordsDialog()创建的对话框,而不是现在的表单提交,“自定义确认”对话框中的“删除联系人”按钮应承担提交值为“删除选定项”的表单的任务,就像“提交”按钮现在所做的那样。
如果没有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>
脚本:
要为模式创建按钮,请执行以下操作:
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();
}
此功能将单击用户最初单击的按钮下方的隐藏按钮。如果您正确设置此按钮,表单应提交您需要的所有信息。