Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Confirm()

Status
Not open for further replies.

nelco

Programmer
Apr 4, 2006
93
US
I have added this function to my delete button...

function DeleteRec(vnd)
{
var answer = confirm ("Do You Want To Delete Vendor "+vnd+"?\nClicking on the 'Ok' button to continue delete\nClick on 'Cancel' button to cancel.");
if (!answer) return false;


I get the Confirm message but problem is even if I select Cancel, it goes and deletes the record.
I was just wondering where I am going wrong. Let me know.
Thanks
 
Not enough info. Does the form submit to another page that handles the deletion? If so, show us the form tag and where you call the function above. Also, show the rest of the function that you provided part of.

Lee
 
OK,

From my main page when I click on the link, I get a popup where I can update, insert or delete record.
If I click on delete, It gives me a confirmation box to continue or cancel. Irrespective of what I do, It gives me message Record has been deleted and popup closes and my main page refreshes.

<input name="del" type="submit" value="Delete" onClick="DeleteRec('<%=strCc%>');">

function DeleteRec(vnd)
{
var answer = confirm ("Do You Want To Delete Vendor "+vnd+"?\nClicking on the 'Ok' button to continue delete\nClick on 'Cancel' button to cancel.");
if (!answer) return false;
}

if (Request.form("del") <>"") Then
strVndNo = request.form("VendorNo")
set Doupdate = Server.CreateObject("ADODB.Command")
Doupdate.ActiveConnection = MM_Store_Operations_STRING
Sqldel = "DELETE FROM [store_operations].[dbo].[LPM_UTILITY]WHERE SAP_COST_CENTER_NO = '"& strCc&"'"
'response.write Sqldel
'response.end
Doupdate.CommandText = sqldel
Doupdate.Execute() %>
<script language="javascript" type="text/javascript">
alert('Record has been deleted.');
window.opener.RefreshData();
this.window.close();

</script>
<% end if %>

On my main page: I have this function:

function RefreshData()
{
alert('Now I am refreshing my data');
document.form1.submit();
}
 
Please read:

strCC = request.form("TxtCostCenter") instead of

strVndNo = request.form("VendorNo")

Thanks
 
You cannot add an onsubmit handler to a submit button, it is only valid for a form tag. Set up your form like this instead:

Code:
<form id="whatever" [!]onsubmit="return DeleteRec('<%=strCc%>');"[/!]>
   <input name="del" type="submit" value="Delete" [red][s]onClick="DeleteRec('<%=strCc%>');"[/s][/red]>
</form>

-kaht

Looking for a puppy?

silky-icon-left.gif
[small]Silky Terriers are small, relatively odorless dogs that shed no fur and make great indoor pets.[/small]
silky-icon-right.gif
 
And make sure you copy and paste your code in when you give your example so we see what's actually there.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top