confirm delete (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


jonance -> confirm delete (3/25/2001 20:16:00)

Hi,

I have a database that users can add, update, and delete items in. The delete option is a hyperlink going to the page with the sql code to delete the listing with paramaters passed. I need something that will say "Are you sure you want to delete?" before the deletion, giving them a chance to cancel or accept. I tried a couple of scripts but they were on the page with the code and even if you canceled it would send you back to the other page but the item was still deleted. Thanks in advance for your help.

Thanks,

John





Vince from Spain -> RE: confirm delete (3/26/2001 20:39:00)

Hi John,
this simple bit of javascript works for me every time . . .

In the head section . . .

<script language="JavaScript">
<!--
function delrec(id) {
cmsg = "¿Seguro que quiere borrar este archivo?\n"
if (confirm(cmsg)) {
window.location="anotherpage.asp?id=" + id;
}
}
// -->
</script>

Then form your links like . . .
<a href="javascript:delrec('<%=RS("productID")%>')">go to top</a>

I've also illustrated how you could change a Querystring parameter (like anotherpage.asp?rectodelete=45 for instance).

All the best

Vince

------------------
Internet Business Solutions S.L.(Spain)





Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.046875