Click to See Complete Forum and Search --> : delete confirmation with cf and javascript


bozak
10-08-2003, 11:30 AM
I have looked around the forums for about an hour for a simple example of how to do this, but can't seem to find anything appropriate.

what I am trying to do is confirm an action in Cold Fusion for deleting an item

Basically, I have a picture that when the user clicks on it, reloads the CF page with some variables in the URL, which trigger a SQL statement to get executed ... something like this
....some code

<cfif action is 'delete'>
do some sql to delete it
</cfif>

....more code


<a href="./thispage.cfm?action=delete"><img src="pic.jpg"></a>

what I'd like is to have a javascript that pops up a window, lets the user know that they are about to delete the item, offers to cancel or conintue and then either closes the popup without deleting the item (cancel) or continues to process the cf page as is ....


I'll keep looking through the forum.

Thank you very much ...
:cool:

pyro
10-08-2003, 11:36 AM
You could use something like this:

<a href="http://www.w3.org" onclick="return confirm('Are you sure about that?');">Do something</a>

bozak
10-08-2003, 11:44 AM
yes my hydro carbon incineration friend ..
that was the trick ...

since you seem to be working the forums like a pimp ...

can you recommend any good texts with examples.

I am still way in the dark on js ...

I get the basic idea but frquently get hung on syntax ...

Id like to understand stuff more ...

so

onclick="return confirm('Are you sure about that?');"

return confirm is built in to js?
I can see (duh) where the message is passed in.

where can I learn about more of these prebuilt things etc?

bozak
10-08-2003, 11:45 AM
thanks again man.

have a nice day

pyro
10-08-2003, 12:00 PM
Yes, confirm is a prebuilt function in JavaScript. The return before it tells it we want to return the results of the function (for confirm, either true or false). Then, depending on what is returned, the link will either execute or not (yes, if true; no, if false).

You can take a look at http://devedge.netscape.com/library/manuals/2000/javascript/1.5/reference/ for a good reference on JavaScript. Also, glad to hear you like the Web Dev FAQ's site... :)