Home > Backend Development > PHP Tutorial > 11行php+js 求改错解决方案

11行php+js 求改错解决方案

WBOY
Release: 2016-06-13 12:01:08
Original
886 people have browsed it

11行php+js 求改错
<script><br />function del(){<br /> if (!confirm("您确定要删除这些记录吗?已提交记录将不能删除!")){<br /> return;<br /> }<br /> document.location = "delete1.php?lmbs<span style="color: #FF0000;">=<?php echo urlencode("主题管理");<span style="color: #FF0000;">?>&id<span style="color: #FF0000;">=<?php echo $array['id'];<span style="color: #FF0000;">?>"; <br />}<br /></script>




如果在document.location后加入百度网址,可以正常实现功能。
或许是js里套php哪里错了?
------解决方案--------------------
 
<br />function del(){<br />  if (!confirm("您确定要删除这些记录吗?已提交记录将不能删除!")){<br /> return;<br />  }<br />  document.location = "delete1.php?lmbs=<?php echo urlencode("主题管理");?>&id=<?php echo $array['id'];?>";  <br />}<br /><br />
Copy after login


逻辑问题,你的document.location最后得到字符串中的ID没有任何值。。。。

PHP 是服务器端的,JS是客户端的,你的id=明显的没有值。这里的id只能通过JS来获取

<br /><br />function del()<br />{<br />  if (!confirm("您确定要删除这些记录吗?已提交记录将不能删除!")){<br /> return;<br />  }<br />else<br />{<br /><br />//这里写点代码用JS来获取选中的ID,然后用","合并,作为字符串返回<br />//<br /><br /><br /> document.location = "delete1.php?lmbs=<?=urlencode("主题管理")?>&id="+id;  <br /><br />}<br /> <br />}<br />
Copy after login







------解决方案--------------------
上面发的还有些问题!
<script></script>
<script><br />$(document).ready(function(){<br />$("#delUserById").click(function(){<br />var id = $(this).parent().find('.userId').val();<br />alert(id);<br /> if (!confirm("您确定要删除这些记录吗?已提交记录将不能删除!")){<br /> return;<br /> }<br /> document.location = "delete1.php?lmbs=<?php echo urlencode("主题管理");?>&id="+id; <br />});<br />});<br /></script>



" />



只要你的$array['id']有值,应该可以获取了
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template