如何在javascript警告框中添加php内容或变量?! javascript,php,alertbox [英] How to add php content or variable inside javascript alert box?! javascript, php, alertbox
本文介绍了如何在javascript警告框中添加php内容或变量?! javascript,php,alertbox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Java脚本警报框中添加php内容或php变量?!
我试图让它工作的方法很少,但它只是弹出一个空白框而不是php变量的内容。
How can i add php content or php variable inside Java-script alert box?! I tried to make it work few ways but it is only popping up a blank box rather than the contents of php variable.
这是代码:
<script language="javascript">
$(document).ready(function() {
$("#a").blur(function() {
<?php $b = $_POST['a'];
if(isset($_POST['update'])) {
mysql_query("UPDATE tbl_travel set fld_a='".$_POST[$b]."' where fld_id = '".$_POST["id"]."' ") or die(mysql_error());
} ?>
alert (<?php $b ?>);
});
});
</script>
感谢您的帮助:)
推荐答案
更改此
alert (<?php $b ?>);
到此
alert ('<?php echo $b; ?>');
您需要输出 $ b
并在警报内添加引号。
You need to output the value of $b
and add quotes inside the alert.
关于PHP - echo
About PHP - echo
这篇关于如何在javascript警告框中添加php内容或变量?! javascript,php,alertbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文