| | |
Problem when adding delete confirmation
Please support our ASP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Mar 2007
Posts: 22
Reputation:
Solved Threads: 0
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 :
<SCRIPT LANGUAGE="JavaScript">
function confirmDelete()
{
var agree=confirm("Are you sure to delete?");
if (agree)
return true;
else
return false;
}
</SCRIPT>
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....
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 :
<SCRIPT LANGUAGE="JavaScript">
function confirmDelete()
{
var agree=confirm("Are you sure to delete?");
if (agree)
return true;
else
return false;
}
</SCRIPT>
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....
•
•
Join Date: Mar 2007
Posts: 22
Reputation:
Solved Threads: 0
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 :
<SCRIPT LANGUAGE="JavaScript">
function confirmDelete()
{
var agree=confirm("Are you sure to delete?");
if (agree)
return true;
call del();
else
return false;
}
</SCRIPT>
But that's impossible.
Can you help me aparnesh?
Thanks.
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 :
<SCRIPT LANGUAGE="JavaScript">
function confirmDelete()
{
var agree=confirm("Are you sure to delete?");
if (agree)
return true;
call del();
else
return false;
}
</SCRIPT>
But that's impossible.
Can you help me aparnesh?
Thanks.
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.
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.
Hi there,
Use This function :
If you wanna use form
JavaScript :
HTML :
[html]<form action="" method="get" onSubmit="return confirmation()">
<input name="Submit" type="submit" value="Submit">
</form>
[/html]
if you wanna use the link with Query string
JavaScript :
HTML :
[html]<a href="#" onClick="confirmation1('/update.asp', 'update', 'id=<%=rs("id")%>')">Update Record</a>
<a href="#" onClick="confirmation1('/delete.asp', 'del', 'id=<%=rs("id")%>')">Delete Record</a>[/html]
Best Regards,
Rahul Dev Katarey
Use This function :
If you wanna use form
JavaScript :
ASP Syntax (Toggle Plain Text)
<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]<form action="" method="get" onSubmit="return confirmation()">
<input name="Submit" type="submit" value="Submit">
</form>
[/html]
if you wanna use the link with Query string
JavaScript :
ASP Syntax (Toggle Plain Text)
<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]<a href="#" onClick="confirmation1('/update.asp', 'update', 'id=<%=rs("id")%>')">Update Record</a>
<a href="#" onClick="confirmation1('/delete.asp', 'del', 'id=<%=rs("id")%>')">Delete Record</a>[/html]
Best Regards,
Rahul Dev Katarey
Last edited by katarey; May 5th, 2007 at 5:16 pm.
•
•
Join Date: Mar 2007
Posts: 22
Reputation:
Solved Threads: 0
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 :
<a href="#" onClick="confirmation1('/delete.asp', 'del', 'id=<%=rs("id")%>')">Delete Record</a>
into this :
Response.Write "<a href='#' onclick='confirmation1('/delete.asp', 'del', 'id="&rs("id")&"')'>Delete</a></td>"
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.
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 :
<a href="#" onClick="confirmation1('/delete.asp', 'del', 'id=<%=rs("id")%>')">Delete Record</a>
into this :
Response.Write "<a href='#' onclick='confirmation1('/delete.asp', 'del', 'id="&rs("id")&"')'>Delete</a></td>"
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.
Hi Again,
Problem is in the single quote (') ,double quote (")
Right syntax is this:
<a href="#" onClick="confirmation1('/delete.asp', 'del', 'id=<%=rs("id")%>')">Delete Record</a>
Output will be in HTML :
<a href='#' onclick="confirmation1('/delete.asp', 'del', 'id=1')">Delete</a>
But when you write with asp:
Response.Write "<a href='#' onclick='confirmation1('/delete.asp', 'del', 'id="&rs("id")&"')'>Delete</a>"
Output will be in HTML :
<a href='#' onclick='confirmation1('/delete.asp', 'del', 'id=1')'>Delete</a>
Therefore JavaScript Function Not Working
Regards,
Rahul
Problem is in the single quote (') ,double quote (")
Right syntax is this:
<a href="#" onClick="confirmation1('/delete.asp', 'del', 'id=<%=rs("id")%>')">Delete Record</a>
Output will be in HTML :
<a href='#' onclick="confirmation1('/delete.asp', 'del', 'id=1')">Delete</a>
But when you write with asp:
Response.Write "<a href='#' onclick='confirmation1('/delete.asp', 'del', 'id="&rs("id")&"')'>Delete</a>"
Output will be in HTML :
<a href='#' onclick='confirmation1('/delete.asp', 'del', 'id=1')'>Delete</a>
Therefore JavaScript Function Not Working
Regards,
Rahul
Hi,
I hope you problem already solved, if not so just write that in this way,
I hope you problem already solved, if not so just write that in this way,
ASP Syntax (Toggle Plain Text)
Response.Write "<a href=""" & "#" & """ onclick="& """confirmation1('/delete.asp', 'del', 'id="& rs("id") &"')""" & ">Delete</a>"
![]() |
Similar Threads
- Skip the Recycle Bin Confirmation Message (Windows tips 'n' tweaks)
- RUNDLL32.EXE is not responding (Viruses, Spyware and other Nasties)
Other Threads in the ASP Forum
- Previous Thread: ASP .NET C# SQL on Visual Studio 2003, help?
- Next Thread: Classic sql update question
| Thread Tools | Search this Thread |
archive asp asp.net aspandmssqlserver2005 aspandmssqlserver2005connection aspconnection calendar changeable connection current database databaseconnection diagnostics dreamweaver excel fso html iis microsoft msmsql mssql2005 mssqlserver2005 mssqlserver2005andasp mssqlserverandasp opentextfile record searchbox selectoption server single specfic sqlserver sqlserverconnection toolkit web webserver windows7





