单击警报时打破内部

时间:2015-12-24 11:57:26

标签: php onclick

我有一个带有警报的按钮字段,然后才会被执行。那" onclick"警报代码包含文本。我无法在文本中制动。我该如何解决这个问题?我发现了[这个问题] [1],但我还是无法修复它。问题是当我点击按钮时根本没有任何事情发生。



echo "<tr><td><strong>
<form action='respondent.php' method='post'>
 <input type='hidden' name='rid' value='".$row['rid']."'>
 <input type='hidden' name='firstname' value='".$row['firstname']."'> 
<a href='respondent.php'><button>".$row['firstname']." ".$row['lastname']."</button></a>

 <input type='submit' name='submit' value='Select'>
 </form>
 </strong></td> 
 
 <td>".$row['email']."</td> 
 <td>".$row['pointsummary']."</td> 
 <td>".$row['datetime']."</td>
 
<td> 
<input type='button' action='deleterespondent.php' value='Delete' 
onclick="return confirm('Are you sure you \n want to delete?');">
</td>
</tr>";
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:1)

以这种方式使用<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> \n \ n在字符串中使用,因此无需使用confirm('Are you sure you \n want to delete?');

DEMO:https://jsfiddle.net/b95yrrwu/

答案 1 :(得分:1)

删除single quotes&#39;在\n附近

<强>代码:

<input type='button' action='deleterespondent.php' value='Delete' 
onclick=\"return confirm('Are you sure you \\n want to delete?');\">

<强>输出

enter image description here