我想要得到一个确认消息点击删除(这可能是一个按钮或图像)。如果用户选择“Ok”,那么删除就完成了,否则如果点击“Cancel”,什么都不会发生。
当点击按钮时,我尝试回显这个,但是回显的东西使我的输入框和文本框失去了它们的样式和设计。
我想要得到一个确认消息点击删除(这可能是一个按钮或图像)。如果用户选择“Ok”,那么删除就完成了,否则如果点击“Cancel”,什么都不会发生。
当点击按钮时,我尝试回显这个,但是回显的东西使我的输入框和文本框失去了它们的样式和设计。
当前回答
var x = confirm("Are you sure you want to send sms?");
if (x)
return true;
else
return false;
其他回答
我认为最简单不显眼的解决方案是:
链接:
<a href="http://link_to_go_to_on_success" class="delete">Delete</a>
Javascript:
$('.delete').click(function () {
return confirm("Are you sure?");
});
对于选择选项框,要做到这一点要困难得多。 下面是解决方案:
<select onchange="if (this.value == 'delete' && !confirm('THIS ACTION WILL DELETE IT!\n\nAre you sure?')){this.value=''}">
<option value=''> </option>
<option value="delete">Delete Everything</option>
</select>
使用jQuery:
$(".delete-link").on("click", null, function(){
return confirm("Are you sure?");
});
对于“删除确认消息”使用:
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Searching.aspx/Delete_Student_Data",
data: "{'StudentID': '" + studentID + "'}",
dataType: "json",
success: function (data) {
alert("Delete StudentID Successfully");
return true;
}
当你在PHP和mysql中删除一些东西时,设置一个确认消息…
使用以下脚本代码:
<script>
function Conform_Delete()
{
return conform("Are You Sure Want to Delete?");
}
</script>
使用下面的HTML代码:
<a onclick="return Conform_Delete()" href="#">delete</a>