简体   繁体   English

删除仅在Internet Explorer中不起作用

[英]Delete does not work in only Internet Explorer

So this code works in every browser except Internet Explorer. 因此,此代码可在除Internet Explorer之外的所有浏览器中使用。 How can I make it work in IE? 如何使它在IE中工作?

//html code // html代码

<form action="postdel.php?id=<?php echo $id; ?>" method="POST" onsubmit="return confirm('Confirm: DELETE <?php echo $productname; ?>?');">

<input type="hidden" value="delete" title='Delete Item'> 
 <button style='height:33px; width:50px'>
      <img src="../css/images/delete_25.png" />
 </button>
</form>

//postdel.php //postdel.php

ob_start();
include("../conn.php");

$stmt = $mysqli->prepare("DELETE FROM specials WHERE id = ?");
$stmt->bind_param('i', $_GET['id']);
$stmt->execute();
$stmt->close();

header('Location: foo.php');

$id is just a random number. $id只是一个随机数。 I'm assuming the problem is with the JavaScript popup to confirm the delete. 我假设问题出在JavaScript弹出窗口以确认删除。 Because when you press OK, it accepts, removes the dialog and sits back on the same page. 因为当您按OK时,它接受,删除对话框,并位于同一页面上。 All other browsers, it confirms, and goes to the foo page. 确认所有其他浏览器,然后转到foo页面。

You could try giving the form a name using the name attribute, which is applied to the form: 您可以尝试使用name属性为表单命名,该属性应用于表单:

name="deleteform"

would render the following: 将呈现以下内容:

form action="postdel.php?id=<?php echo $id; ?>" method="POST" onsubmit="return confirm('Confirm: DELETE <?php echo $productname; ?>?');" name="deleteform">

anyway, I don't know why this isn't working. 无论如何,我不知道为什么这不起作用。 I just did this as my solution, hopefully it will help someone else. 我只是将此作为我的解决方案,希望它将对其他人有所帮助。

I just basically got rid of the form all together and just used the button to execute the delete command. 我只是基本上摆脱了所有形式,只是使用按钮来执行删除命令。

//html // html

<button onclick="location.href='postdel.php?id=<?php echo $id; ?>'" style='height:33px; width:50px;'><img src="../css/images/delete_25.png" border="0"/></button>

//php // php

ob_start();
include("../conn.php");

$stmt = $mysqli->prepare("DELETE FROM specials WHERE id = ?");
$stmt->bind_param('i', $_GET['id']);
$stmt->execute();
$stmt->close();

header('Location: foo.php');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM