function selectitem()
{ document.all.myform.action="selectitem.asp";
document.all.myform.submit();
}
function submitt()
{ document.all.myform.action="addcustomer.asp?action=add";
check();
}
</script>
</head>
<% set ds=server.CreateObject("adodb.recordset")
ds.open "select * from customer order by customerno desc",conn,3,3
if ds.eof then
tempno=1
else
tempno=cint(ds("customerno"))+1
end if
if len(tempno)<5 then
i=5-len(tempno)
for j=1 to i
tempno="0"&cstr(tempno)
next
end if
ds.close
%>
<body>
<p> </p>
<table width="629" border="0" cellspacing="1" cellpadding="3" align="center" class="table">
<form name="myform" action="" method="post" onSubmit="return check()">
<tr>
<td width="134" align="right">Date:</td>
<td colspan="3"><input type="text" name="date" value="<%=formatdatetime(now(),2)%>"></td>
</tr>
<tr>
<td align="right" width="134">Customer NO.: </td>
<td colspan="3"><input type="text" name="customerno" value="<%=tempno%>"></td>
</tr>
<tr>
<td align="right" width="134">Customer name: </td>
<td colspan="3"><input name="Customername" type="text" id="Customername" value="<%=request("Customername")%>"></td>
</tr>
<tr>
<td align="right" width="134">Address:</td>
<td width="168"><input name="Address" type="text" id="Address" value="<%=request("Address")%>">
</td>
<td align="right" width="92"> State:</td>
<td width="206"><input name="State" type="text" id="State" value="<%=request("State")%>"></td>
</tr>
<tr>
<td align="right" width="134">Tel:</td>
<td><input name="Tel" type="text" id="Tel" value="<%=request("Tel")%>">
</td>
<td align="right">Zip_code:</td>
<td><input name="Zip_code" type="text" id="Zip_code" value="<%=request("Zip_code")%>"></td>
</tr>
<tr>
<td align="right" width="134">Purchase date: </td>
<td colspan="3"><input name="Purchasedate" type="text" id="Purchasedate" onfocus=setday(this) value="<%=request("Purchasedate")%>"></td>
</tr>
<tr>
<td align="right" width="134">Purchase loaction: </td>
<td colspan="3"><input name="Purchaseloaction" type="text" id="Purchaseloaction" value="<%=request("Purchaseloaction")%>"></td>
</tr>
<tr>
<td align="right" width="134">invoice no:</td>
<td colspan="3"><input name="invoiceno" type="text" id="invoiceno2" value="<%=request("invoiceno")%>"></td>
</tr>
<tr>
<td align="right" width="134">Purchase Product item: </td>
<td colspan="3"><select name="bigclass" onChange="selectitem()">
<option value="">select big class</option>
<% set rs1=server.CreateObject("adodb.recordset")
rs1.open "select * from bigclass",conn,3,3
do while not rs1.eof
%>
<option value="<%=rs1("bigclassid")%>" <%if request("bigclass")<>"" then if cint(trim(rs1("bigclassid")))=cint(trim(request("bigclass"))) then response.Write("selected") end if end if%>><%=rs1("bigclassname")%></option>
<% rs1.movenext
loop%>
</select>
<select name="smallclass" onChange="selectitem()">
<option value="">select small class</option>
<% if request("bigclass")<>"" then
set rs2=server.CreateObject("adodb.recordset")
rs2.open "select * from smallclass where bigclassid="&cint(trim(request("bigclass")))&"",conn,3,3
do while not rs2.eof%>
<option value="<%=rs2("smallclassid")%>" <%if request("smallclass")<>"" then if cint(trim(rs2("smallclassid")))=cint(trim(request("smallclass"))) then response.Write("selected") end if end if%>><%=rs2("smallclassname")%></option>
<% rs2.movenext
loop
end if
%>
</select>
<select name="product" onChange="selectitem()">
<option value="">select product</option>
<%
if request("smallclass")<>"" then
set rs3=server.CreateObject("adodb.recordset")
rs3.open "select * from product where smallclassid="&cint(trim(request("smallclass")))&"",conn,3,3
do while not rs3.eof
%>
<option value="<%=rs3("productid")%>" <%if request("product")<>"" then if cint(trim(rs3("productid")))=cint(trim(request("product"))) then response.Write("selected") end if end if%>><%=rs3("productname")%></option>
<%rs3.movenext
loop
end if%>
</select>
<!-- <select name="item" onChange="selectitem()">
<option value="">select item</option>
<%
if request("product")<>"" then
set rs4=server.CreateObject("adodb.recordset")
rs4.open "select * from item where productid="&cint(trim(request("product")))&"",conn,3,3
do while not rs4.eof
%>
<option value="<%=rs4("itemid")%>"
<%if request("item")<>"" then
if cint(trim(rs4("itemid")))=cint(trim(request("item"))) then
itemn=trim(rs4("itemname"))
response.Write("selected")
end if
end if%>><%=rs4("ino")%></option>
<%rs4.movenext
loop
end if%>
</select> <input type="text" value="<% if request("item")<>"" then response.Write(itemn) end if%>" size="12">-->
</td>
</tr>
<tr>
<td align="right" width="134">Defective Reason: </td>
<td colspan="3"><select name="reason" onChange="selectitem()">
<option value="">select reason</option>
<% if request("product")<>"" then
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from product where productid="&cint(trim(request("product")))&"",conn,3,3
reason=rs("reason")
if reason<>"" then
k=cint(ubound(Split(reason,",")))
dsql="select distinct * from reason where reasonid="&cint(split(reason)(0))
for i=1 to k
dsql=dsql&" or reasonid="&cint(split(reason)(i))
next