Javascript + PHP?

Get help on web editors (Frontpage, Dreamweaver) and web languages (HTML, ASP, PHP).
Post Reply
JEdiWaNNaBE
Registered User
Posts: 576
Joined: 16 Jul 2002, 02:00
Location: Inside your Fridge.
Contact:

Javascript + PHP?

Post by JEdiWaNNaBE »

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?
Image
LordyHaHa
Registered User
Posts: 4
Joined: 20 Aug 2004, 02:00

Post by LordyHaHa »

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)
}
Pulse
Registered User
Posts: 12
Joined: 26 Mar 2004, 02:00

Post by Pulse »

If the link/button is part of a form, you can use the onSubmit of the form to send the form or not,

<form onSubmit="return dothis();">
</form>

if a false is returned the form is not submitted, so you can put a redirect in the javascript instead of returning a false.
Post Reply