HTML按钮(onlick)在将数据发送到MySQL表时不起作用
html button (onlick) not working when sending data to mysql table
所以我在html页面上有一个表单,可以从mysql表中检索数据。用户可以修改这些数据,或删除整行。我有一个具有删除整行功能的 html 按钮,使用该按钮,我有一个 javascript 函数,该函数显示一个确认弹出框,确认用户是否要删除它。如果他们单击"是",则将其发送到执行删除的另一个 php 页面。问题是当我单击确认框时没有任何反应,它只是停留在同一页面上。这是我的 html 和 javascript 代码:
<form class="form-inline" method=GET action="envoieModifierAlbumAdmin.php">
<table class="table table-striped">
<tr>
<td><button type="button" class="btn btn-danger" onclick="verif()">Supprimer Cet Album</button>
</td><td></td><td></td>
</tr>
<tr>
<td><label for="exampleInputName2">id: </label>
<input readonly type="text" class="form-control" value="<?php echo "$donnees[id]"?>" id="exampleInputName2" name="id">
</td><td></td><td></td>
</tr>
<tr>
<td><label for="exampleInputName2">Nom d'album: </label>
<input type="text" class="form-control" id="exampleInputName2" name="titre" value="<?php echo "$donnees[titre]"?>"></td>
<td></td><td></td>
</tr>
</table>
</form>
<script>
function verif(){
var x;
if(confirm("Vous êtes sûr que vous voulez supprimer ce compte?") == true){
document.location="supprimerAlbumAdmin.php?id=$_GET['id']";
}
else
}
</script>
唯一的问题是按钮,上表的其他部分只是为了显示用户正在修改的内容的示例。提前感谢!
你的值应该是这样的
value="<?php echo $_GET['id'] ?>"
不是这样的
value="<?php echo "$donnees[id]"?>"
并将按钮类型更改为提交
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script>
function verif(){
alert("hi");
var x;
if(confirm("Vous êtes sûr que vous voulez supprimer ce compte?") == true){
//window.location.replace("https://google.com");
//exit();
return true;
}
else
{
return false;
}
}
</script>
<form class="form-inline" method="GET" action="envoieModifierAlbumAdmin.php">
<table class="table table-striped">
<tr>
<td><label for="exampleInputName2">id: </label>
<input readonly type="text" class="form-control" value="" id="exampleInputName2" name="id">
</td><td></td><td></td>
</tr>
<tr>
<td><label for="exampleInputName2">Nom d'album: </label>
<input type="text" class="form-control" id="exampleInputName2" name="titre" value=""></td>
<td></td><td></td>
</tr>
<tr>
<td><button type="submit" class="btn btn-danger" onclick="verif()">Supprimer Cet Album</button>
</td><td></td><td></td>
</tr>
</table>
</form>
尝试
function verif(){
var x;
if(confirm("Vous êtes sûr que vous voulez supprimer ce compte?") == true){
window.location.href="supprimerAlbumAdmin.php?id=<?php echo $_GET['id']; ?>";
}
else
}
尝试以下操作:
function verif(){
var x;
if(confirm("Vous êtes sûr que vous voulez supprimer ce compte?")){
window.location.href="supprimerAlbumAdmin.php?id=<?php echo $_GET['id']; ?>";
}
}
相关文章:
- electronic BrowserWindow的最小高度和宽度在hide()show()方法之后不起作用
- 监视函数从服务返回不起作用,但作用域函数起作用
- 在node.js-mysql中执行UPDATE查询不起作用
- mysql时间戳格式的Javascript regex不起作用
- 同一页面上的 mysql 中的 Ajax 加载表不起作用
- HTML按钮(onlick)在将数据发送到MySQL表时不起作用
- php中的mysql查询不起作用,但它在另一个php文件中起作用
- Javascript和Mysql调用在页面上都不起作用
- 使用PHP/MYSQL在phonegap中注册;不起作用
- 为什么我的 php 连接到 mysql 服务器不起作用
- MySQL 查询的预先准备的列名不起作用
- 更改单选按钮的事件以从MySQL表中获取值,不起作用
- PHP/MySql 到 JavaScript 不起作用
- 使用 PHP /MySQL JavaScript 创建一个简单的 Web 开发测试,但不起作用
- MySQL循环中查询Javascript不起作用
- 从数据库mysql中检索数据不起作用
- PHP Mysql Insert Into不起作用,没有错误,没有数据发布到数据库,早些时候同一页面也起作用
- MYSQL数据插入查询不起作用
- 多个动态下拉选择菜单不起作用-PHP MySQL Jquery
- 使用Phonegap、AJAX、PHP和mySQL登录不起作用