PDA

View Full Version : Java Scripts Pop Up Message Box


victoria_1018
08-28-2002, 02:32 AM
Hi all,
I had a problem in creating an interactive box.
Below is the codes I used for the interactive box.

<Script>
var stay=confirm("Delete Report?? Please click ok to proceed or cancal to go back to the main menu!")
if (stay)
window.location="DeleteReport2.asp"
else
window.location="main.asp"
</Script>

The program works without any bug. Although the program take me to the main page after I had click cancal, but the selected report is deleted at the same time.
What can I do to ensure the program only delete the report when I click ok, and take me to the main menu without deleting the report when I click cancal?
In the following 2 reply will be the codes I used for the program.
Thanks

Regards
Victotia

victoria_1018
08-28-2002, 02:34 AM
<% Option Explicit %>
<%
if session("staffID") = "" then
Response.Redirect "Login.asp"
end if

%>
<html>
<head>
<title>Knetworks Cornerstone, the company with your IT solutions.</title>
<Script>
var stay = confirm("Delete Report?? Please click ok to proceed or cancal to go back to the main menu!")
if (stay) {
window.location="DeleteReport2.asp";
}
else{
window.location="main.asp";
}
</Script>
</head>

<body bgcolor="#FFFFFF" topmargin="0" marginwidth="0" marginheight="0" link="#000080" vlink="#99CCFF" >
<%
Dim custConn, custrs,SQL
Set custConn = Server.CreateObject("ADODB.Connection")
Set custrs = Server.CreateObject("ADODB.Recordset")

custConn.Open "driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("\SalesReport") & "\SaleReport.mdb"

custrs.Open "Customer", custConn, 3, 3
session("customerID") = Request.QueryString("search") 'Request.Form("customerID")

'set staffRs = reportConn.Execute("Select LoginID, AccessStatus from staff where staffID like '"&session("staffID")&"'")
'set custrs = custConn.Execute("Select customerID, salute, Company, ContactPerson, Address, PostalCode, ContactTel, ContactFax, ExtensionNo from Customer where customerID like '"&session("customerID")&"'")

dim searchCustomer
searchCustomer = Request.QueryString("search")

%>
<div align="center">
<%

set custrs = custConn.Execute("Select * from Customer where customerID like '"&searchCustomer&"'")
'Response.Write("<H2><b>"&Ucase(session("customerID"))&"</b></H2>")

while not custrs.EOF
%>

<table width="755" border="0">
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><img src="Images/kc_logo1.gif" width="199" height="30"></td>
</tr>
</table>
<br>
<form method="POST" action="../SalesReport/DeleteCustomer3.asp" >

<div align="center">
<center>
<table border="0" width="560" cellspacing="0" cellpadding="5">
<tr>
<td width="560" bgcolor="#000080">
<p align="center"><b><font face="Arial" color="#FFFFFF" size="3">Update
Customer Record</font></b>
</td>
</tr>
</table>
</center>
</div>
<table border="0" width="560" height="30" bordercolor="#FFFFFF" align="center">
<tr>
<td width="200" height="0" bgcolor="#FFFFFF"><b><font size="2" face="Verdana" color="#000000">Customer
ID</font></b></td>
<td width="360" height="0" bgcolor="#FFFFFF"><font size="2" face="Verdana"><%=custrs("customerID")%></font></td>
</tr>
<tr>
<td width="200" height="0" bgcolor="#FFFFFF"><b><font size="2" face="Verdana" color="#000000">Salutation</font></b></td>
<td width="360" height="0" bgcolor="#FFFFFF"><font size="2" face="Verdana">
<%=custrs("salute")%></font></td>
</tr>
<tr>
<td width="200" height="0" bgcolor="#FFFFFF"><b><font size="2" face="Verdana" color="#000000">Company</font></b></td>
<td width="360" height="0" bgcolor="#FFFFFF"><%=custrs("Company")%></td>
</tr>
<tr>
<td width="200" height="0" bgcolor="#FFFFFF"><b><font size="2" face="Verdana" color="#000000">Contact
Person</font></b></td>
<td width="360" height="0" bgcolor="#FFFFFF"><font size="2" face="Verdana">
<input type="text" name="ContactPerson" VALUE=<%= custrs("ContactPerson") %> size="40" ></font></td>
</tr>
<tr>
<td width="200" height="0" bgcolor="#FFFFFF"><b><font size="2" face="Verdana" color="#000000">Address</font></b></td>
<td width="360" height="0" bgcolor="#FFFFFF"><font size="2" face="Verdana">
<input type="text" name="Address" VALUE=<%= custrs("Address") %> size="40">
</font></td>
</tr>
<tr>
<td width="200" height="0" bgcolor="#FFFFFF"><b><font color="#000000" face="Verdana" size="2">Postal
Code</font></b></td>
<td width="360" height="0" bgcolor="#FFFFFF"><font size="2" face="Verdana">
<input type="text" name="PostalCode" VALUE=<%= custrs("PostalCode") %> size="6">
</font></td>
</tr>
<tr>
<td width="200" height="0" bgcolor="#FFFFFF"><b><font color="#000000" face="Verdana" size="2">Contact
Telephone</font></b></td>
<td width="360" height="0" bgcolor="#FFFFFF"><font size="2" face="Verdana">
<input type="text" name="ContactTel" VALUE=<%= custrs("ContactTel") %> size="8">
</font></td>
</tr>
<tr>
<td width="200" height="0" bgcolor="#FFFFFF"><b><font color="#000000" face="Verdana" size="2">Contact
Fax</font></b></td>
<td width="360" height="0" bgcolor="#FFFFFF"><font size="2" face="Verdana">
<input type="text" name="ContactFax" VALUE='<%= custrs("ContactFax") %>' size="8">
</font></td>
</tr>
<tr>
<td width="200" height="0" bgcolor="#FFFFFF"><b><font color="#000000" face="Verdana" size="2">Extension
No</font></b></td>
<td width="360" height="0" bgcolor="#FFFFFF"><font size="2" face="Verdana">
<input type="text" name="ExtensionNo" VALUE=<%= custrs("ExtensionNo") %> size="10">
</font></td>
</tr>

<tr>
<td width="200" height="0" bgcolor="#FFFFFF"><font size="2" face="Verdana"><b>Contract
Type</b></font></td>
<td width="360" height="0" bgcolor="#FFFFFF">
<font size="2" face="Verdana"><input type="text" name="Contract" VALUE='<%= custrs("Contract") %>' size="30">
</font>
</td>
</tr>

<tr>
<td width="200" height="0" bgcolor="#FFFFFF"><font size="2" face="Verdana"><b>Remarks</b></font></td>
<td width="360" height="0" bgcolor="#FFFFFF"><font size="2" face="Verdana"><input type="text" name="Remark" VALUE='<%= custrs("Remark") %>' size="50">
</font></td>
</tr>

</table>
<p align="center"><font face="Verdana">
<input type="submit" value="Proceed To Update Customer Record" name="B1">
<input type="reset" value="Reset Information" name="B2">
</font></p>
<p align="center">&nbsp;</p>
</form>



<%
custrs.MoveNext
wend
%>
<%
custConn.Close
Set custrs = Nothing
Set custConn = Nothing
%>
<table>
<tr>
<td width="140" height="24">
</td>
<td width="140" height="24" align="center">
<b><font color="#999999" size="2" face="Arial"><a href="menuCheck.asp">Main
Menu</a></font></b>
</td>
<td width="140" height="24" align="center">
<b><font color="#999999" size="2" face="Arial"><a href="logout.asp">Logout</a></font></b>
</td>
<td width="140" height="24">
</td>
</tr>
<tr>
<td width="560" height="24" colspan="4">
<p class="copyright"><font size="1" face="Verdana" color="#999999">Copyright
?Knetworks Cornerstone<br>
Last Modified on
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" -->
</font>
</td>
</tr>
<tr>
<td width="560" height="24" colspan="4">&nbsp;</td>
</tr>
</table>
<p>&nbsp;</p>

</body>
</Html><body bgcolor="#FFFFFF" topmargin="0" marginwidth="0" marginheight="0" link="#000080" vlink="#99CCFF" >

victoria_1018
08-28-2002, 02:35 AM
<body bgcolor="#FFFFFF" topmargin="0" marginwidth="0" marginheight="0" link="#000080" vlink="#99CCFF" >
<%
Dim custConn, custrs,SQL, SQL2, SQL1,SQL3
Set custConn= Server.CreateObject("ADODB.Connection")
Set custrs= Server.CreateObject("ADODB.Recordset")

custConn.Open "driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("\SalesReport") & "\SaleReport.mdb"
custrs.Open "Customer", custConn, 3, 3
Set custrs = custConn.Execute("select * from Customer where Company like '"&session("customerID")&"'")

Dim customerID, Company
customerID= session("customerID")
Company = session("Company")


SQL = "Delete from Customer WHERE customerID = '"&session("customerID")&"'"
SQL1 = "Delete from Customer WHERE customerID = "&session("customerID")&""

'SQL2 = "SELECT COUNT(*) FROM TrackCustomer where company='"&session("company")&"' "
SQL3= "INSERT INTO DeleteCustomer (company, Date_Time, StaffID, [SQL] ) SELECT '"& session("customerID") &"' AS Expr1, #"& NOW() &"# AS Expr2, '" & session("staffID")&"' AS Expr3, '"& SQL1 &"' AS Expr4;"

'response.write SQL2
Set custrs= custConn.Execute(SQL)
Set Custrs= custConn.Execute(SQL3)
%>
<table width="755" border="0">
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><img src="Images/kc_logo1.gif" width="199" height="30"></td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td valign="top" width="560" height="315" colspan="4">
<form method="POST" action="UpdateCustomer.asp">
<div align="center">
<center>
<table border="0" width="560" bgcolor="#000080" cellspacing="0" cellpadding="5">
<tr>
<td width="100%" bgcolor="#000080">
<p align="center"><b><font face="Arial" color="#FFFFFF" size="3">Confirm&nbsp;
Customer Record Update</font></b>
</td>
</tr>
</table>
</center>
</div>
<p align="center"><b><font size="2" face="Verdana">The Customer Record
Allocated With Customer ID:
<% Response.Write(""&customerID&"") %>
Has Been</font></b></p>
<p align="center"><b><font size="2" face="Verdana">&nbsp;Successfully
Updated Into The System Database</font></b></p>
<p align="center"><b><font size="2" face="Verdana">To Continue Updating
Existing Customer Record,&nbsp; Please Make Use&nbsp;</font></b></p>
<p align="center"><b><font size="2" face="Verdana">&nbsp;Of The Update
Function&nbsp; Activated By Clicking On The Button Located Below&nbsp;</font></b></p>
<p align="center">&nbsp;</p>
<p align="center"><font face="Verdana">
<input type="submit" value="Click to Return to Update Customer Record Page" name="B1">
</font></p>
</form>
<%
custConn.Close
Set custrs= Nothing
Set custConn= Nothing
%>
<tr>
<td width="140" height="24">
</td>
<td width="140" height="24" align="center">
<b><font size="2" face="Arial"><a href="menuCheck.asp">Main Menu</a></font></b>
</td>
<td width="140" height="24" align="center">
<b><font size="2" face="Arial"><a href="logout.asp">Logout</a></font></b>
</td>
<td width="140" height="24">
</td>
<td width="12" height="24"></td>
</tr>
<tr>
<td width="560" height="24" colspan="4">
<p class="copyright"><font size="1" face="Verdana" color="#999999">Copyright
© Knetworks Cornerstone<br>
Last Modified on
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" -->
</font>
</td>
<td width="12" height="24">&nbsp;</td>
</tr>
<tr>
<td width="560" height="24" colspan="4">&nbsp;</td>
<td width="12" height="24">&nbsp;</td>
</tr>
</table>
<p>&nbsp;</p>

</body>

</html>

glenngv
08-28-2002, 04:45 AM
don't start a new thread. you should have continued on the previous thread http://codingforums.com/showthread.php?s=&threadid=4863 so that others can follow the discussions.

i haven't fully checked the codes because it is too long.
is the asp code that deletes the record in the same page as the javascript code that displays the confirm box?
my advice is to put them separately.

victoria_1018
08-28-2002, 04:49 AM
Hi Glenn,
What you mean is to have the javascript put on a new page and attach it into my asp program?
Thanks
Victoria

glenngv
08-28-2002, 06:50 AM
can you describe what the page does in the codes you posted?

victoria_1018
08-28-2002, 07:01 AM
This page is to delete the sales report selected by the user. The pop up message is to confirm the user really want to have the report delected.

glenngv
08-28-2002, 07:30 AM
are the 2 codes you posted in a single page? then why do you have 2 body and html tags?
can you explain more, like the report details are displayed to the user first, then there is a delete button, then when this button is clicked, it displays the confirm box then go to the delete page.
if you make it clearly, the better i can help you.

victoria_1018
08-28-2002, 08:11 AM
The whole delete program consists of 4 pages. The codes that I post into this forum is the last two pages of the whole proigram.
I will just briefly type outv the functions of the whole delete program.

The 1st page, Delect Customer. I didn't post this code onto forum.
-User select customer information to delete.
- User can either type the name of the customer company or select their name from the alphabet links.

The 2nd page, Delect Customer Check. I didn't post this code onto forum.
-system will search db for this customer's record. If record found, a link will be displayed and user will click this link to take them to delete customer 1.

The 3rd page, Delect Customer. This page is posted into forum this morning
-this page is to display the detail customer's company information the user will be deleting.
-When the user click the submit button to delete the report, the pop up message will appear to confirm the user really want to delete the report.
-If the user click ok, program will go to delete customer comfirmation page, this piece ois posted into the forum this morning.
-If the user click no, the system will take the user back to the main menu.

The 4th page, Delect CustomerConfirmation. This page is posted into forum this morning
-This page is to confirm the information is deleted.

Here is how the whole delete program run. If you need the codes for the first two page, let me know and I will post them to you.

Thanks Glenn

Regards
victoria

glenngv
08-28-2002, 09:04 AM
in your 3rd page where you display the information, put the confirm() box in a function:

<Script>
function verify(){
var stay = confirm("Delete Report?? Please click ok to proceed or cancal to go back to the main menu!")
if (stay) {
window.location="DeleteReport2.asp";
}
else{
window.location="main.asp";
}
return false;
}
</Script>

then in the form tag:

<form onsubmit="return verify()">

hope this is what you want

victoria_1018
08-28-2002, 09:13 AM
Hi Glenn,
Thank A lot. The codes work really well.
Thank You.

Warmest Regards
Victoria:o