I want to use javascript and php together.
I have a table of notices/articles in the admin section of my website which the admin can delete, what i want to do is when admin clicks on the delete link(button) then it must popup a confirmation box asking if it's ok to delete the article/notice then the person would click ok and php would delete the entry from the database.
How would i go about doing this?
Javascript + PHP?
-
- Registered User
- Posts: 576
- Joined: 16 Jul 2002, 02:00
- Location: Inside your Fridge.
- Contact:
have an onlcick on the dleete button that calls the javascript function . The function does the confirmation with an alert box.
You get the result (TRUE or FALSE) back from the alert box and if its TRUE (delete the object) then redirect the user in the javascript function to the php page that does the deletion.
Just looking at the stuff I worte below, it might not be the Alert function, but I'm sure there is one for a Yes/No popup. (I think alert only has OK button on it).
pseudo code example:
function delete(id) //id is the article number
{
var ans;
if (var = alert("You sure?"))
redirect("del_article.php?".id)
}
You get the result (TRUE or FALSE) back from the alert box and if its TRUE (delete the object) then redirect the user in the javascript function to the php page that does the deletion.
Just looking at the stuff I worte below, it might not be the Alert function, but I'm sure there is one for a Yes/No popup. (I think alert only has OK button on it).
pseudo code example:
function delete(id) //id is the article number
{
var ans;
if (var = alert("You sure?"))
redirect("del_article.php?".id)
}