Good Afternoon,
I am trying to after a user press the cancel button on my insert page, it clears the form and then checks to see if the recordset is empty. If it is empty it stays on the insert page if not it redirects itself to another page. Is this possible, if so can an example code be given?
I posted my code below.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/connDB.asp" -->
<!--#include file="functions.asp"-->
<% If Request("butSaveUpdate") <> "" Then %>
<%
Dim CmdInsert__ProducerID
CmdInsert__ProducerID = ""
if(Request("ProducerID") <> "") then CmdInsert__ProducerID = Request("ProducerID")
Dim CmdInsert__LastName
CmdInsert__LastName = ""
if(Request("LastName") <> "") then CmdInsert__LastName = Request("LastName")
Dim CmdInsert__FirstName
CmdInsert__FirstName = ""
if(Request("FirstName") <> "") then CmdInsert__FirstName = Request("FirstName")
Dim CmdInsert__PreferredName
CmdInsert__PreferredName = ""
if(Request("PreferredName") <> "") then CmdInsert__PreferredName = Request("PreferredName")
Dim CmdInsert__Title
CmdInsert__Title = ""
if(Request("Title") <> "") then CmdInsert__Title = Request("Title")
Dim CmdInsert__Phone
CmdInsert__Phone = null
if(Request("Phone") <> "") then CmdInsert__Phone = fnparsePhoneNumber (Request("Phone"))
Dim CmdInsert__Ext
CmdInsert__Ext = ""
if(Request("Ext") <> "") then CmdInsert__Ext = Request("Ext")
Dim CmdInsert__Email
CmdInsert__Email = ""
if(Request("Email") <> "") then CmdInsert__Email = Request("Email")
Dim CmdInsert__Notes
CmdInsert__Notes = ""
if(Request("Notes") <> "") then CmdInsert__Notes = Request("Notes")
%>
<%
set CmdInsert = Server.CreateObject("ADODB.Command")
CmdInsert.ActiveConnection = MM_connDB_STRING
CmdInsert.CommandText = "dbo.spProducerContactInsert"
CmdInsert.CommandType = 4
CmdInsert.CommandTimeout = 0
CmdInsert.Prepared = true
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@RETURN_VALUE", 3, 4)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@ProducerID", 3, 1,4,CmdInsert__ProducerID)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@LastName", 200, 1,50,CmdInsert__LastName)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@FirstName", 200, 1,30,CmdInsert__FirstName)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@PreferredName", 200, 1,30,CmdInsert__PreferredName)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@Title", 200, 1,50,CmdInsert__Title)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@Phone", 20, 1,14,CmdInsert__Phone)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@Ext", 200, 1,5,CmdInsert__Ext)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@Email", 200, 1,50,CmdInsert__Email)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@Notes", 200, 1,500,CmdInsert__Notes)
CmdInsert.Execute()
Response.redirect "producerdetail_contacts.asp?ProducerID=" + cmdInsert__ProducerID
%>
<% End If %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function fnCancelInsert() {
// Reset all fields on Insert form
document.frmInsert.reset();
}
//-->
</script>
<style type="text/css">
<!--
@import url("CSS/NRCG.css");
-->
</style>
</head>
<body>
<form id="frmInsert" name="frmInsert" method="post" action="">
<table width="500" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="150"> </td>
<td width="250"> </td>
<td width="50"><input name="butSaveUpdate" type="submit" class="Nav" id="butSaveUpdate" value="Save" /></td>
<td width="50"><input name="butCancelInsert" type="button" class="Nav" id="butCancelInsert" value="Cancel" onclick="javascript:fnCancelInsert();" /></td>
</tr>
<tr>
<td><label>Name (F/L)</label>
</td>
<td colspan="3"><input name="FirstName" type="text" id="FirstName" />
<input name="LastName" type="text" id="LastName" /></td>
</tr>
<tr>
<td><label>Preferred Name</label>
</td>
<td colspan="3"><input name="PreferredName" type="text" id="PreferredName" />
<input name="producerID" type="hidden" id="producerID" /></td>
</tr>
<tr>
<td><label>Title</label></td>
<td colspan="3"><input name="Title" type="text" id="Title" />
</td>
</tr>
<tr>
<td><label>Phone/Ext</label></td>
<td colspan="3"><input name="Phone" type="text" id="Phone" />
/
<input name="Ext" type="text" id="Ext" />
</td>
</tr>
<tr>
<td><label>E-mail</label></td>
<td colspan="3"><input name="Email" type="text" id="Email" /></td>
</tr>
<tr>
<td><label>Notes</label></td>
<td colspan="3"><input name="Notes" type="text" id="Notes" /></td>
</tr>
</table>
</form>
</body>
</html>
I am trying to after a user press the cancel button on my insert page, it clears the form and then checks to see if the recordset is empty. If it is empty it stays on the insert page if not it redirects itself to another page. Is this possible, if so can an example code be given?
I posted my code below.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/connDB.asp" -->
<!--#include file="functions.asp"-->
<% If Request("butSaveUpdate") <> "" Then %>
<%
Dim CmdInsert__ProducerID
CmdInsert__ProducerID = ""
if(Request("ProducerID") <> "") then CmdInsert__ProducerID = Request("ProducerID")
Dim CmdInsert__LastName
CmdInsert__LastName = ""
if(Request("LastName") <> "") then CmdInsert__LastName = Request("LastName")
Dim CmdInsert__FirstName
CmdInsert__FirstName = ""
if(Request("FirstName") <> "") then CmdInsert__FirstName = Request("FirstName")
Dim CmdInsert__PreferredName
CmdInsert__PreferredName = ""
if(Request("PreferredName") <> "") then CmdInsert__PreferredName = Request("PreferredName")
Dim CmdInsert__Title
CmdInsert__Title = ""
if(Request("Title") <> "") then CmdInsert__Title = Request("Title")
Dim CmdInsert__Phone
CmdInsert__Phone = null
if(Request("Phone") <> "") then CmdInsert__Phone = fnparsePhoneNumber (Request("Phone"))
Dim CmdInsert__Ext
CmdInsert__Ext = ""
if(Request("Ext") <> "") then CmdInsert__Ext = Request("Ext")
Dim CmdInsert__Email
CmdInsert__Email = ""
if(Request("Email") <> "") then CmdInsert__Email = Request("Email")
Dim CmdInsert__Notes
CmdInsert__Notes = ""
if(Request("Notes") <> "") then CmdInsert__Notes = Request("Notes")
%>
<%
set CmdInsert = Server.CreateObject("ADODB.Command")
CmdInsert.ActiveConnection = MM_connDB_STRING
CmdInsert.CommandText = "dbo.spProducerContactInsert"
CmdInsert.CommandType = 4
CmdInsert.CommandTimeout = 0
CmdInsert.Prepared = true
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@RETURN_VALUE", 3, 4)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@ProducerID", 3, 1,4,CmdInsert__ProducerID)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@LastName", 200, 1,50,CmdInsert__LastName)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@FirstName", 200, 1,30,CmdInsert__FirstName)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@PreferredName", 200, 1,30,CmdInsert__PreferredName)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@Title", 200, 1,50,CmdInsert__Title)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@Phone", 20, 1,14,CmdInsert__Phone)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@Ext", 200, 1,5,CmdInsert__Ext)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@Email", 200, 1,50,CmdInsert__Email)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@Notes", 200, 1,500,CmdInsert__Notes)
CmdInsert.Execute()
Response.redirect "producerdetail_contacts.asp?ProducerID=" + cmdInsert__ProducerID
%>
<% End If %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function fnCancelInsert() {
// Reset all fields on Insert form
document.frmInsert.reset();
}
//-->
</script>
<style type="text/css">
<!--
@import url("CSS/NRCG.css");
-->
</style>
</head>
<body>
<form id="frmInsert" name="frmInsert" method="post" action="">
<table width="500" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="150"> </td>
<td width="250"> </td>
<td width="50"><input name="butSaveUpdate" type="submit" class="Nav" id="butSaveUpdate" value="Save" /></td>
<td width="50"><input name="butCancelInsert" type="button" class="Nav" id="butCancelInsert" value="Cancel" onclick="javascript:fnCancelInsert();" /></td>
</tr>
<tr>
<td><label>Name (F/L)</label>
</td>
<td colspan="3"><input name="FirstName" type="text" id="FirstName" />
<input name="LastName" type="text" id="LastName" /></td>
</tr>
<tr>
<td><label>Preferred Name</label>
</td>
<td colspan="3"><input name="PreferredName" type="text" id="PreferredName" />
<input name="producerID" type="hidden" id="producerID" /></td>
</tr>
<tr>
<td><label>Title</label></td>
<td colspan="3"><input name="Title" type="text" id="Title" />
</td>
</tr>
<tr>
<td><label>Phone/Ext</label></td>
<td colspan="3"><input name="Phone" type="text" id="Phone" />
/
<input name="Ext" type="text" id="Ext" />
</td>
</tr>
<tr>
<td><label>E-mail</label></td>
<td colspan="3"><input name="Email" type="text" id="Email" /></td>
</tr>
<tr>
<td><label>Notes</label></td>
<td colspan="3"><input name="Notes" type="text" id="Notes" /></td>
</tr>
</table>
</form>
</body>
</html>