Confirm Deletion with pop-up confirmation box

Source: Internet
Author: User
Tags window
We all know UD's method of deleting records, it needs to be validated with a new page, if the deleted page directly into the form of command (refer to my many delete tutorials), and more hasty (often easy to delete the wrong record), the following, the small field is a pop-up confirmation box to achieve the confirmation delete, the effect is as shown
 
Now let's get started!
1, first of course, there is a you want to delete the content of the (how to connect the database, how to cycle please refer to other basic tutorials, here is not much to say), and do a good job of the cycle, as shown

2, to implement the confirmation box, of course, to use JavaScript, the following is the code:
Code:
--------------------------------------------------------------------------------
<script language= "JavaScript" >
function Confirmer ()
{
if (Confirm () Make sure you want to delete this category (confirm the deletion) and what is relevant to this category! ")){
window.location.href= ' delete page address ';
}
}
</script>
[/code]
We add this code to the table row of the circular record (be sure to be in the line, why?) Wait for the meeting to know), the effect is as shown

3, modify the code. Next we need to replace the contents of the code with the dynamic content of our records, see:
"Confirm deletion" replaces "<%=" (RsLinkType.Fields.Item ("Lt_name"). Value)%> "(This is your own to confirm the content)
"Remove page address" replaces the hyperlink with Go to Detail page "Delete", I am Here "lt_del.asp?<%= Mm_keepnone & Mm_joinchar (mm_keepnone) &" Id_ Linktype= "& RsLinkType.Fields.Item (" Id_linktype "). Value%> "
So, the current code content becomes the following:
The following are program code:
<script language= "JavaScript" >
function Confirmer ()
{
if (Confirm () Make sure that you want to delete this category (<%= (RsLinkType.Fields.Item ("Lt_name"). Value), as well as the content associated with this category!%> ")){
Window.location.href= ' lt_del.asp?<%= Mm_keepnone & Mm_joinchar (mm_keepnone) & "Id_linktype=" & RsLinkType.Fields.Item ("Id_linktype"). Value%> ';
}
}
</script>
Then add "" to the original "delete" link, as follows:
The following is the program code: <a href= "#" > Delete </A>
4, the next is the most critical step. We can now try to browse the page, uh!! How to confirm the content and click to delete the content does not match? Ah, Xiao Tian can not deceive everyone, otherwise must be bruised ^_^! In fact, the reason is very simple, because we click on the link, we call this confirmer () function, but in the duplicate record display, we call the function is the same, the program does not know which one to tune! So the content of the confirmation is not consistent. It's good to know why! I don't know if you noticed. UD Generated record loop code
The following are program code:
<%
while ((repeat1__numrows <> 0) and (not rslinktype.eof))
%>
Loop content ...
......
......
<%
Repeat1__index=repeat1__index+1
Repeat1__numrows=repeat1__numrows-1
Rslinktype.movenext ()
Wend
%>
We look at the variable "Repeat1__index" here, which is the identification of the number of loops, and we're going to use it to distinguish each function that is invoked. Add it to the back of the function name and see:
The following are program code:
<script language= "JavaScript" >
function confirmer<%=repeat1__index%> ()
{
if (Confirm () Make sure that you want to delete this category (<%= (RsLinkType.Fields.Item ("Lt_name"). Value), as well as the content associated with this category!%> ")){
Window.location.href= ' lt_del.asp?<%= Mm_keepnone & Mm_joinchar (mm_keepnone) & "Id_linktype=" & RsLinkType.Fields.Item ("Id_linktype"). Value%> ';
}
}
</script>
Of course, the location of the call must also be changed:
The following is the program code: <a href= "#" > Delete </A> change to
<a href= "#" > Delete </A>
Now try it out and see if it's already on the map.
5, the last step. Pass parameters (here is id_linktype) to delete the intense page tl_del.asp, how to delete the command do refer to my "Multiple deletion tutorial" (You can search the previous posts, you can find in the resources)
The tutorial is written here, have any questions on the replies! In fact, we learn UD and ASP at the same time, should try to combine some JavaScript and HTML, because ASP is a kind of and HTML with the closest language, we have to make good use of!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.