Javascript alerts and using php variables in javascript

J M

I have the below section of code where I want to display how many orders have been added if conditions of the $orderstat are met. The alert works but not with the $orderstat variable inside it. Can anyone see what I am doing wrong? Thanks in advance!

    session_start();
$orderstat = $_SESSION['orderstat']; 
if ( $orderstat == "1" || $orderstat == "2" || $orderstat == "3" || $orderstat == "4") {
echo '<script language="javascript">';
**echo 'alert('<?php echo $orderstat; ?>' + "order/s successfully added to Job")';**
echo '</script>';
}
session_destroy();
user3535945

Change this line echo 'alert('<?php echo $orderstat; ?>' + "order/s successfully added to Job")';

to

echo 'alert("'.$orderstat.' order/s successfully added to Job")';

You are nesting the php again and again in line echo 'alert('' + "order/s successfully added to Job")';

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Equating Javascript and PHP Variables

분류에서Dev

Modifying PHP Session Variables with JavaScript

분류에서Dev

Trouble with php variables and ajax javascript

분류에서Dev

Change Javascript Variables Using <input>

분류에서Dev

javascript alerts refuse to work in form validation?

분류에서Dev

Javascript static variables and using in different pages

분류에서Dev

Javascript constructor with closure using outside variables referencing other variables

분류에서Dev

grab php output using javascript in table

분류에서Dev

Changing color type of video using Javascript or PHP

분류에서Dev

dynamic calculation of input fields using php javascript

분류에서Dev

Multiple Javascript Variables in URLs

분류에서Dev

Javascript DOM confusion with variables

분류에서Dev

Javascript variables use in HTML

분류에서Dev

javascript setTimeout() outputs save as variables

분류에서Dev

Accessing nested JavaScript objects with variables

분류에서Dev

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

분류에서Dev

Countdown in hrs/minutes/seconds in php function using javascript

분류에서Dev

Javascript: Extract correct json from php script using id

분류에서Dev

how to uppercase multiple id (checkbox in php using javascript)

분류에서Dev

How do I see the list of all variables in scope along with their values in Javascript using the Developer Tools on Google Chrome?

분류에서Dev

Php output breaks the Javascript

분류에서Dev

Javascript passing a variable to PHP

분류에서Dev

Ajax PHP/Javascript array

분류에서Dev

php cookie secure javascript

분류에서Dev

JavaScript와 PHP

분류에서Dev

javascript php post undefined

분류에서Dev

PHP Variable in JavaScript Tag

분류에서Dev

Javascript in php not working?

분류에서Dev

Php and Javascript slider issue

Related 관련 기사

뜨겁다태그

보관