How to add php content or variable inside javascript alert box?! javascript, php, alertbox

Pooja

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 :)

Sergio

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] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Create javascript alert in PHP

분류에서Dev

How to use php inside of javascript?

분류에서Dev

Javascript passing a variable to PHP

분류에서Dev

PHP Variable in JavaScript Tag

분류에서Dev

php code not executing after calling a javascript alert

분류에서Dev

program php and alert javascript on form html

분류에서Dev

WordPress 및 PHP의 JavaScript Inside JavaScript

분류에서Dev

Select Box PHP Array => Javascript On Click Div

분류에서Dev

Filter Alert Javascript, how to

분류에서Dev

bold contents displayed in javascript alert box?

분류에서Dev

Call Javascript function with parameters inside PHP

분류에서Dev

How to access attributes of php object inside a array of php objects from javascript

분류에서Dev

How to Capture Szimek/Signature_Pad with PHP (Capture Javascript into PHP Variable)?

분류에서Dev

Passing php arrays variable to javascript for leaflet map

분류에서Dev

Can't use my php variable in JavaScript

분류에서Dev

Send variable to external PHP file from JavaScript

분류에서Dev

Javascript cant get value from PHP variable?

분류에서Dev

load php variable with jquery and work with javascript

분류에서Dev

Add content to PHP WP excerpt

분류에서Dev

Google Maps - Finding all the markers inside a given radius Javascript/Php

분류에서Dev

javascript call inside php where loop not working and breaks query

분류에서Dev

How to pass PHP data to external JavaScript

분류에서Dev

PHP or Javascript - How to Destroy a Website In specific time

분류에서Dev

Using jQuery to assign a string echoed by PHP to a variable in Javascript

분류에서Dev

Pass a variable from a javascript function to another php file

분류에서Dev

how do I add a second variable to a simple javascript function?

분류에서Dev

Php output breaks the Javascript

분류에서Dev

Ajax PHP/Javascript array

분류에서Dev

php cookie secure javascript

Related 관련 기사

  1. 1

    Create javascript alert in PHP

  2. 2

    How to use php inside of javascript?

  3. 3

    Javascript passing a variable to PHP

  4. 4

    PHP Variable in JavaScript Tag

  5. 5

    php code not executing after calling a javascript alert

  6. 6

    program php and alert javascript on form html

  7. 7

    WordPress 및 PHP의 JavaScript Inside JavaScript

  8. 8

    Select Box PHP Array => Javascript On Click Div

  9. 9

    Filter Alert Javascript, how to

  10. 10

    bold contents displayed in javascript alert box?

  11. 11

    Call Javascript function with parameters inside PHP

  12. 12

    How to access attributes of php object inside a array of php objects from javascript

  13. 13

    How to Capture Szimek/Signature_Pad with PHP (Capture Javascript into PHP Variable)?

  14. 14

    Passing php arrays variable to javascript for leaflet map

  15. 15

    Can't use my php variable in JavaScript

  16. 16

    Send variable to external PHP file from JavaScript

  17. 17

    Javascript cant get value from PHP variable?

  18. 18

    load php variable with jquery and work with javascript

  19. 19

    Add content to PHP WP excerpt

  20. 20

    Google Maps - Finding all the markers inside a given radius Javascript/Php

  21. 21

    javascript call inside php where loop not working and breaks query

  22. 22

    How to pass PHP data to external JavaScript

  23. 23

    PHP or Javascript - How to Destroy a Website In specific time

  24. 24

    Using jQuery to assign a string echoed by PHP to a variable in Javascript

  25. 25

    Pass a variable from a javascript function to another php file

  26. 26

    how do I add a second variable to a simple javascript function?

  27. 27

    Php output breaks the Javascript

  28. 28

    Ajax PHP/Javascript array

  29. 29

    php cookie secure javascript

뜨겁다태그

보관