gudfry Posted July 18, 2008 Share Posted July 18, 2008 hi maybe i was in the the wrong area, Sory for convenience, I was looking for a code to test, and i found this code. when I reun it to my browser it has no action happen, i dont know if i was correct. the code is not function well. any idea with this to make the code work?? pls help me. <?php msgbox("Are you sure?", "confirm"); $result=""; if ($result == "ok") { // Perform some "ok" action here... } else { // Perform some "cancel" action here... } function msgbox($msg, $type) { if ($type == "alert") { // Simple alert window ?> <script language="JavaScript"> alert("<?php echo $msg; ?>"); </script> <?php } elseif ($type == "confirm") { ?> <script language="JavaScript"> if (confirm("<? echo $msg; ?>")) { <?php $result == "ok"; ?> } else { <?php $result == "cancel"; ?> } </script> <?php } } ?> thanks in advance Link to comment https://forums.phpfreaks.com/topic/115347-php-passing-through-to-javascript-for-msgbox/ Share on other sites More sharing options...
unkwntech Posted July 18, 2008 Share Posted July 18, 2008 You can not mix javascript and PHP like this.... PHP is processed at the server and the JavaScript is processed in the browser you will need to use some ajax pass the info to a php script. Link to comment https://forums.phpfreaks.com/topic/115347-php-passing-through-to-javascript-for-msgbox/#findComment-593036 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.