OK... um...
maybe I asked my initial question wrong. I can get the script to execute when I need it to just fine. (I was doing it differently, and your way is much better, so thanks for that.) What I need to do is to use the boolean value returned by the javascript function as the conditional in my PHP if statement.
Let me give you a rundown on what I'm doing... maybe that will help clear things up.
the page is called and the user is presented with 3 options, one of which is to delete a record from the database (the other to optios I have working just fine, so there should be no reason to go into those).
the user clicks one of the 3 options (for our purposes, they want to delete a record).
the page then calls itself, passing a parameter called 'action'. This parameter is how the page knows what the user wants to do.
an sql query is run retreiving all records from the DB. The user picks from that list which record they want to delete.
this causes the page to call itself again, this time passing the 'action' parameter, and an 'ID' parameter (the record ID).
the page uses the 'ID' parameter to identify the record, then deletes it from the database.
That's where things stand now - everything works. What I want do is to change that last step slighty. I want to use a javascript confirmation box to force the user to confirm that they do indeed want to delete that specific record. So that last step would change like this:
the page uses the 'ID' parameter to identify the record, then uses a javascript confirmation box to confirm the record to be deleted. If the user confirms it (clicks ok/yes), the record is deleted. If the user does not confirm (clicks cancel/no), they are taken back to the list of records.
And this is the direction I've been going...
if ($action=="AddRecord") {
do a whole bunch of stuff
} else if ($action=="EditRecord") {
do a whole bunch of other stuff
} else if ($action=="DeleteRecord") {
if ($ID!="") {
run javascript showing confirmation box
if (boolean value from confirmation box = true) {
delete the record
} else {
retrieve and display the list of records
}
} else {
retrieve and display the list of records
}
} else {
die ("error interpreting the action command");
}