-1

my code is in php, I wanted to create a pop up window when I push the delete button, that asks for confirmation for delete. As I read on internet I create a pop up window with java script like

 if (confirm('<?php echo "sure to delete data from $start to $end for device $eui?" ?>') == true) {
            var text ='<?php delete($eui,$start,$end,$Nrows);?>';
        } else {
            //nothing
        }

if we push ok on the pop up it should run delete function(that is in php an in charge of deleting the data) if cancel, nothing. but anyway it runs the delete function and deletes the data.

Can you please help me how to make this correctly?

  • 3
    You seem to be confused about where and when each part runs. PHP runs on the server, generating the document. JavaScript runs on the client's browser, at the time PHP already finished it's work. – Noam May 25 '22 at 13:23
  • You need AJAX to post the user response to PHP to go further: delete or cancel. – ild flue May 25 '22 at 13:25
  • 1
    @ildflue more generic: you'll need a HTTP request (how it's send to the server isn't relevant) – Honk der Hase May 25 '22 at 13:38
  • so can you tell how should I make the window? – Andia Fathi May 26 '22 at 13:16

0 Answers0