Hello everybody,

I am wanting to use a javascript confirm popup (OK returns TRUE/Cancel returns FALSE) to determine whether I need to run part of my PHP code.

I could only think of one way to try, and this is it:

echo "<script type=\"javascript\">
var popbox = confirm(\"Are you sure you want to delete " . $x . " entries?\");
if(popbox){";

php_code();

echo "}
</script>";

But... since Javascript is client-side I know this might not be possible, so my question is, CAN I do this? And how?

It's called Ajax. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.