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.
Here is the code:
<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>
Thank You for your Help :)
Change this
alert (<?php $b ?>);
to this
alert ('<?php echo $b; ?>');
You need to output the value of $b
and add quotes inside the alert.
About PHP - echo
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다