How to use javascript using PHP?
Scenario:
I created a filtering using IF ELSE where when the user click BOX A AND
BOX B... Then assuming the BOX A is already full, after the user hit the
"SAVE BUTTON", a confirmation message will display saying that... "The Box
you chosen is already full. Do you want to save the other items?"
Here's my Code:
else if($box== "BOX A" && $row[item] == "100")
{
<?php
echo "<script type='text/javascript'>";
echo "var r=confirm('The Box you chosen is already full. Do you want
to save the other items?')";
echo "if (r==true){";
echo "alert('You pressed OK!')}";
echo "else{";
echo "alert('You pressed Cancel!')}";
echo "</script>";
?>
}
I have a problem with the code and when I try to trace it using echo
"enter here"; its always stop after the program read this code
echo "<script type='text/javascript'>";
Then it will jump it in here:
echo "</script>";
RESULT:
its not displaying the pop up message ... So all I need is to display the
pop up message and I dont know why, why its not displaying... There is no
button involve for the displaying of confirmation message...It will just
pass by in if else and then it will prompt up if the user wants to
continue the saving if one of the box is already full if not he/she will
press the cancel...
NOTE: I'm only a beginner for PHP and Javascript..
Thank you in advance.
No comments:
Post a Comment