Reputation: 15
I have a button when user click on that button it appends a dropdown list to the HTML and I have used PHP to retrieve data from database in fill the dropdown list, while i try this code it is not working for me! any idea?
$(".pageSheet").on("click", ".bt2", function () {
$(this).closest(".pageIn").append("<p>Image: <select name='image'>
<?php include'scripts/addImage.php'; addImg(); ?></select><br><button class='deleteCon'>Delete</button></p>"); i++;});
Upvotes: 0
Views: 175
Reputation: 18457
You cannot append <?php // code here ?>
to an already rendered webpage using JavaScript and expect PHP to parse it. PHP parses the page while it is being handled by the webserver attending to the request. If you want JavaScript (client-side) to interact with something PHP generates from a Database (server-side), you need to look into AJAX.
Upvotes: 2