clientuser
Programmer
I have this page that I am trying to save data to an access db, but each time I click submit it just blinks for a sec like its doing something and then stops.. it also happens when I dont put anything in the fields and I have a script to check the fields, but even thats not working:
Code:
<% Response.Buffer = true %>
<!--#include file = "conn.asp"-->
<%
dim strdate
strdate = now()
%>
<html>
<head>
<title>~~~~SA-Order entry~~~~</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
function check1(){
if (document.form1.fname.value =="" )
{
form1.fname.focus;
error=1;
}
else
if (document.form1.lname.value=="")
{
form1.lname.focus;
error=1;
}
else
if (document.form1.address.value=="")
{
form1.address.focus;
error=1;
}
else
if (document.form1.city.value=="")
{
form1.city.focus;
error=1;
}
else
if (document.form1.zip.value=="")
{
form1.zip.focus;
error=1;
}
else
if (document.form1.status.value=="")
{
form1.status.focus;
error=1;
}
else
{
form1.submit();
}
}
</script>
</head>
<body bgcolor="#ffffff">
<form name="form1" method="post" action="addorder.asp" onSubmit="check1();">
<table width="100%" border="0" cellspacing="5" cellpadding="5">
<tr>
<td bgcolor="#000000"><strong><font color="#FFFFFF">Enter in a new order:</font></strong></td>
</tr>
</table>
<table width="40%" border="0" cellspacing="5" cellpadding="5">
<tr>
<td bgcolor="#666666"><table width="100%" border="0" cellpadding="5">
<tr>
<td bgcolor="#000000"><font color="#FFFFFF">Date order entered:</font>  <input name="dateentered" type="text" value="<%=strdate%>" id="dateentered" disabled="true"></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="5" cellspacing="0" bordercolor="#666666">
<tr bgcolor="#CCCCCC">
<td width="40%"><font color="#666666">Order number:</font></td>
<td width="60%"><input name="ordnum" type="text" id="ordnum" size="20" maxlength="20"></td>
</tr>
<tr bgcolor="#CCCCCC">
<td width="40%"><font color="#666666">First Name:</font></td>
<td width="60%"><input name="fname" type="text" id="fname" size="20" maxlength="20"></td>
</tr>
<tr bgcolor="#CCCCCC">
<td><font color="#666666">Last Name:</font></td>
<td><input name="lname" type="text" id="lname" size="20" maxlength="20"></td>
</tr>
<tr bgcolor="#CCCCCC">
<td><font color="#666666">Address:</font></td>
<td><input name="address" type="text" id="address" size="50" maxlength="50"></td>
</tr>
<tr bgcolor="#CCCCCC">
<td><font color="#666666">City:</font></td>
<td><input name="city" type="text" id="city" size="20" maxlength="20"></td>
</tr>
<tr bgcolor="#CCCCCC">
<td><font color="#666666">State:</font></td>
<td><input name="state" type="text" id="state" size="20" maxlength="20"></td>
</tr>
<tr bgcolor="#CCCCCC">
<td><font color="#666666">Zip:</font></td>
<td><input name="zip" type="text" id="zip" size="20" maxlength="20"></td>
</tr>
<tr bgcolor="#CCCCCC">
<td><font color="#666666">Status:</font></td>
<td><input name="status" type="text" id="status" size="20" maxlength="20"></td>
</tr>
</table>
</table>
<tr bgcolor="#CCCCCC">
<td> </td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table></td>
</tr>
</table>
<%
dim strdateenter,strordnum,strfname,strlname,straddress,strcity,strstate,strzip,strstatus
strdateenter = Request.form("dateentered")
strordnum = Request.form("ordnum")
strfname = Request.form("fname")
strlname = Request.form("lname")
straddress = Request.form("address")
strcity = Request.form("city")
strstate = Request.form("state")
strzip = Request.form("zip")
strstatus = Request.form("status")
if ( strdateenter <> "" and strordnum <> "" and strfname <> "" and strlname <> "" and straddress <> "" and strcity <> "" and strstate <> "" and strzip <> "" and strstatus <> "") then
sql= "SELECT * FROM tblsa WHERE ordernum ='" & strordnum & "'"
conn.ConnectionTimeout = 15
conn.CommandTimeout = 10
conn.Mode = 3
conn.Open
rs.Open sql,conn,3,3
if rs.eof then
rs.AddNew
rs("DateEntered") = Request.form("dateentered")
rs("ordernum") = Request.form("ordnum")
rs("fname") = Request.form("fname")
rs("lname") = Request.form("lname")
rs("address") = Request.form("address")
rs("city") = Request.form("city")
rs("zip") = Request.form ("zip")
rs("status") = Request.form ("status")
rs.Update
'Response.Redirect("default.asp")
Response.write("Order Saved with no errors.")
else
Response.write("Order Already Exist")
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
end if
%>
</form>
</html>