Can anyone tell me why this Javascript isn't working? (The following is the PHP code:)
if ($quantity>$inventory) {
echo '<script language="javascript">
var i = confirm("There are ';
echo number_format($inventory);
echo ' copies in inventory in ';
echo $warehouse_name;
echo '.nnThis order is for ';
echo number_format($quantity);
echo ' copies.nnThat is ';
echo number_format($difference);
echo ' more than are available.nnClick OK to create a backorder for this itemnor Cancel to abort.");
if (!i) window.close();';
echo '</script>';
}
The idea is simple: A confirm box opens with a message. If the user clicks OK, the PHP code continues. If the user clicks Cancel, the window should close without executing any more PHP code. Right now, it doesn't matter which button you click: the PHP code just continues regardless.
How can I fix this?