473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

vbscript, msgbox, delete confirmation

Hi all!

Please improve on the following code to make sure the record gets deleted
only when the function returns false. Now I see the msgbox, but the record
gets deleted no matter the user clicks yes or no.

Thanks in advance.

Asif
=======================
Code:
<script language="VBScript">
Function confirmDelete()
answer = MsgBox("Are you sure you want to delete this one?",4,"Delete")
If answer = 6 Then
confirmDelete = true
Else
confirmDelete = false
End If
End Function

</script>

<%
Response.Write "<a href=AprDelete.asp?ID=" & RS.Fields("ID") & "><img
src=images/delete.gif border=0 onClick = 'ConfirmDelete()'></a>"
%>

Jul 22 '05 #1
3 14008
"Asif Rahman" wrote in message
news:uK****************@TK2MSFTNGP14.phx.gbl...
: Please improve on the following code to make sure the record gets deleted
: only when the function returns false. Now I see the msgbox, but the record
: gets deleted no matter the user clicks yes or no.
:
: Thanks in advance.
:
: Asif
: =======================
: Code:
: <script language="VBScript">
: Function confirmDelete()
: answer = MsgBox("Are you sure you want to delete this one?",4,"Delete")
: If answer = 6 Then
: confirmDelete = true
: Else
: confirmDelete = false
: End If
: End Function
:
: </script>
:
: <%
: Response.Write "<a href=AprDelete.asp?ID=" & RS.Fields("ID") & "><img
: src=images/delete.gif border=0 onClick = 'ConfirmDelete()'></a>"
: %>

Where do you tell it to delete the record? All you're showing is a DHTML
onclick event to validate a question to delete or not but where is the
delete routine code? Hopefully this is on an Intranet since you're using
client-side vbscript and language= is deprecated. type="text/vbscript"
should be used. Since this is an ASP NG, it would help to see the server
side code.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #2
Hi Roaland, Thanks.

Here's the code from the page (AprDelete.asp) that deletes the record:

<%
Dim DB
Set DB = server.CreateObject ("ADODB.Connection")
DB.Mode=3
DB.Open ("Provider = Microsoft.Jet.OLEDB.4.0; Data Source= " +
"C:\database\corp.mdb")

DB.Execute ("Delete * from Appraised where ID=" & Request.QueryString("ID"))
%>

Asif.
"Roland Hall" <nobody@nowhere> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
"Asif Rahman" wrote in message
news:uK****************@TK2MSFTNGP14.phx.gbl...
: Please improve on the following code to make sure the record gets
deleted
: only when the function returns false. Now I see the msgbox, but the
record
: gets deleted no matter the user clicks yes or no.
:
: Thanks in advance.
:
: Asif
: =======================
: Code:
: <script language="VBScript">
: Function confirmDelete()
: answer = MsgBox("Are you sure you want to delete this
one?",4,"Delete")
: If answer = 6 Then
: confirmDelete = true
: Else
: confirmDelete = false
: End If
: End Function
:
: </script>
:
: <%
: Response.Write "<a href=AprDelete.asp?ID=" & RS.Fields("ID") & "><img
: src=images/delete.gif border=0 onClick = 'ConfirmDelete()'></a>"
: %>

Where do you tell it to delete the record? All you're showing is a DHTML
onclick event to validate a question to delete or not but where is the
delete routine code? Hopefully this is on an Intranet since you're using
client-side vbscript and language= is deprecated. type="text/vbscript"
should be used. Since this is an ASP NG, it would help to see the server
side code.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation -
http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp

Jul 22 '05 #3
Because you are not submitting a form returning false will not stop the
browser from going to the delete page.
Try:

<script language="VBScript">
Function confirmDelete( nID )
answer = MsgBox("Are you sure you want to delete this one?",4,"Delete")
If answer = 6 Then
this.location = "aprdelete.asp?id=" & CStr(nID)
Else
confirmDelete = false
End If
End Function

</script>

<%
Response.Write "<a href=""javascript:confirmDelete(" & RS.Fields("ID") &
")"">" & _
<img src=""images/delete.gif"" border=""0"" ></a>"
%>

Also, you might want to get in the habit of using javascript for client-side
script in case your users decide to use a different browser.

--
--Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com

"Asif Rahman" <as**@email.com> wrote in message
news:uL****************@TK2MSFTNGP10.phx.gbl...
Hi Roaland, Thanks.

Here's the code from the page (AprDelete.asp) that deletes the record:

<%
Dim DB
Set DB = server.CreateObject ("ADODB.Connection")
DB.Mode=3
DB.Open ("Provider = Microsoft.Jet.OLEDB.4.0; Data Source= " +
"C:\database\corp.mdb")

DB.Execute ("Delete * from Appraised where ID=" &
Request.QueryString("ID"))
%>

Asif.
"Roland Hall" <nobody@nowhere> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
"Asif Rahman" wrote in message
news:uK****************@TK2MSFTNGP14.phx.gbl...
: Please improve on the following code to make sure the record gets
deleted
: only when the function returns false. Now I see the msgbox, but the
record
: gets deleted no matter the user clicks yes or no.
:
: Thanks in advance.
:
: Asif
: =======================
: Code:
: <script language="VBScript">
: Function confirmDelete()
: answer = MsgBox("Are you sure you want to delete this
one?",4,"Delete")
: If answer = 6 Then
: confirmDelete = true
: Else
: confirmDelete = false
: End If
: End Function
:
: </script>
:
: <%
: Response.Write "<a href=AprDelete.asp?ID=" & RS.Fields("ID") & "><img
: src=images/delete.gif border=0 onClick = 'ConfirmDelete()'></a>"
: %>

Where do you tell it to delete the record? All you're showing is a DHTML
onclick event to validate a question to delete or not but where is the
delete routine code? Hopefully this is on an Intranet since you're using
client-side vbscript and language= is deprecated. type="text/vbscript"
should be used. Since this is an ASP NG, it would help to see the server
side code.

--
Roland Hall
/* This information is distributed in the hope that it will be useful,
but
without any warranty; without even the implied warranty of
merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation -
http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp


Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Sean | last post by:
Hi, I need a pop-up window for user to confirm change. The default button is the second option (No). As the user only use IE, I think the VBScript is an option. The following code only works for...
4
by: Fred | last post by:
Hi. How does one display a confirmation message of either 'Record Updated' or 'Recorded Added"? I've tried the form afterupdate and afterinsert but the afterupdate occurs on an insert too? So...
3
by: vcornjamb | last post by:
Hello, I am developing a web form that contains some buttons and a data grid which has as its last column link buttons that will delete the data associated with that row. Everything works fine,...
4
by: DrData | last post by:
I'm working on an ASP.Net application written in C#. On one page, there are several datagrid controls used to display, edit and delete detail records relating to the master record also displayed on...
1
by: Bucky | last post by:
I haven't found any vbscript code that can stop the form submission/postback after the msgbox. The problem is that asp:button is rendered as <input type="submit"> instead of <input type="button">....
4
by: | last post by:
I have about 20 MsgBox occurance in by program, which I use to inform the user of the progress of the program, or ask confirmation of an action, or simply to act separators to various parts of the...
4
by: viper888 | last post by:
Hi to all, I'm the newly appointed network administrator in our office, and upon scanning all the PCs that are connected to the network, (by the way we're using a windows 2000 server) almost all...
1
by: Vajrala Narendra | last post by:
Hi, all In asp.net project i wrote following code to delete a record for that i used message boxes also there am getting error code in vb.net(asp.net) is Dim Msg As MsgBoxResult If...
2
by: geter | last post by:
Hello, Im using ASP with VBScript. At some point of the code of the application that Im making some changes, I need to get a confirmation from the user if he wants or not to send a confirmation...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.