Sometimes we need to add something in JavaScript code but unfortunately on other side we are using PHP in same file and the value of some one variable is in PHP code.

Suppose


<?php 

$invoiceno = 2343434; // suppose we have value of one variable in PHP code but we want to use it in JavaScript Code

// so this is JavaScript Code but in the form of PHP while using PHP variable value.

 echo "<SCRIPT LANGUAGE='JavaScript'>
       window.alert('Invoice Posted!')
       window.location.href='sales.php?inv=".$invoiceno."';
       ";  



?>