0

I am getting an error for the line of code included in a js file.

$(document).ready(function(){
        //Click "Cancel" button return to Restaurant Manager Page
        $("input[name=btCancel]").click(function(){
            window.location.href = "<?php echo APP_WEB_PATH,"/branch_manager.php?id=".$_GET['id'];?>";
        });
}); 

The uncaught exception points to

window.location.href = "<?php echo APP_WEB_PATH,"/branch_manager.php?id=".$_GET['id'];?>";

Is it because I cannot mix JavaScript with PHP code. Your help is kindly appreciated.

2
Contributors
4
Replies
12
Views
2 Years
Discussion Span
Last Post by solomon_13000
0

Any suggestion how do I decouple the PHP code and JavaScript code? Just an idea, in my PHP page I do this:

<script language='javascript'> var a="<?php echo APP_WEB_PATH,"/branch_manager.php?id=".$_GET['id'];?>"; </script>

Then in my javascript code:

$(document).ready(function(){
        //Click "Cancel" button return to Restaurant Manager Page
        $("input[name=btCancel]").click(function(){
            window.location.href = a;
        });
}); 

I haven't tested. Just a theory. However it looks insecure.

Edited by solomon_13000

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.