954,566 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Problem when adding delete confirmation

Hello.
I have a problem when adding the javascript delete confirmation.
I use a page for both delete and update function.

The delete querystring is just like this :
adm_data.asp?act=del&id=6

And the update goes this way :
adm_data.asp?act=upd&id=6

I use this following code to processing delete:
If Request("act")="del" Then
Call Del() -----------------------> delete sub procedure
End If

I add this javascript confirmation :I include the onclick=confirmDelete() on the delete link which is located on side of each record that is shown.

When i click the delete link, the confirmation box appears. But even though i click the cancel button, the delete is still being executed.

I believe the problem is in the *If Request("act")="del" Then*
Well any masters can help me solved the problem?
Any help will be apreciated.
Thanks....

enggars
Newbie Poster
22 posts since Mar 2007
Reputation Points: 10
Solved Threads: 0
 

Shouldn't it be Request.Querystring("act") ?

aparnesh
Junior Poster
194 posts since Jul 2005
Reputation Points: 20
Solved Threads: 10
 
Shouldn't it be Request.Querystring("act") ?


Yah that will do the same way to Request("act").
The problem is even i click the cancel button, the delete will still being executed.
It is easier if we can call sub procedure from javascript.
Such as :

But that's impossible.

Can you help me aparnesh?
Thanks.

enggars
Newbie Poster
22 posts since Mar 2007
Reputation Points: 10
Solved Threads: 0
 

Why aren't you checking the confirmation before going to the delete page ? I presume in the page that offers both delete and update, you have 2 buttons for delete and update. So when the user clicks the delete button, check for confirmation and if yes, then call the deletepage with adm_data?act=del ... etc.
If you are using a Hyperlink(instead of the button) , then you might try having a confirmation page in between. Clicking on link takes to a page which seeks the confirmation. Clicking yes to the confirmation, sends to adm_data?act=del ... and clicking no returns to original page.

aparnesh
Junior Poster
194 posts since Jul 2005
Reputation Points: 20
Solved Threads: 10
 

Hi there,

Use This function :

If you wanna use form

JavaScript :

<script type="text/javascript">
<!--//
function confirmation() 
    {
        var confirmMe= confirm("Do you really want to Delete??");
            if (confirmMe== true)
                {
                return true
                }
            else
                {
                alert("Action Aborted By User!")
                }
    } 
//-->
</script>


HTML :
[html]

[/html]

if you wanna use the link with Query string

JavaScript :

<script type="text/javascript">
<!--//
function confirmation1(url, act, id) 
    {
        var where_to_go= confirm("Do you really want to Delete??");
            if (where_to_go== true)
                {
                window.location=url+"?"+id+"&"+"act="+act;
                }
            else
                {
                alert("Action Aborted By User!")
                }
    } 
//-->
</script>


HTML :

[html]')">Update Record
')">Delete Record[/html]
Best Regards,
Rahul Dev Katarey

katarey
Junior Poster
167 posts since Jul 2005
Reputation Points: 39
Solved Threads: 23
 

Hai Rahul.
Finally i had to separate the delete process into another page.
But i use your suggestion on the querystring.
It works.
But i have a little problem when i modified the code :

')">Delete Record

into this :

Response.Write "Delete"

I use this code inside ASP delimiter. It should be ok.
But your original code works just fine, i need to know what's wrong with this.

Thanks Rahul.

enggars
Newbie Poster
22 posts since Mar 2007
Reputation Points: 10
Solved Threads: 0
 

Hi Again,

Problem is in the single quote (') ,double quote (")

Right syntax is this:

')">Delete Record

Output will be in HTML :

"confirmation1('/delete.asp', 'del', 'id=1')">Delete

But when you write with asp:

Response.Write "Delete"

Output will be in HTML :

'confirmation1('/delete.asp', 'del', 'id=1')'>Delete

Therefore JavaScript Function Not Working

Regards,
Rahul

katarey
Junior Poster
167 posts since Jul 2005
Reputation Points: 39
Solved Threads: 23
 

Hi,

I hope you problem already solved, if not so just write that in this way,

Response.Write "<a href=""" & "#" & """ onclick="& """confirmation1('/delete.asp', 'del', 'id="& rs("id") &"')""" & ">Delete</a>"


:)

katarey
Junior Poster
167 posts since Jul 2005
Reputation Points: 39
Solved Threads: 23
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You