如何修改表单填写中的必填项为任填项?
代码如下:<%
Sub ProductEdit()
Dim Action, rsRepeat, rs, sql
Action = request.QueryString("Action")
If Action = "SaveEdit" Then
Set rs = server.CreateObject("adodb.recordset")
If Len(Trim(request.Form("ProductName")))<1 Then
response.Write ("<script language='javascript'>alert('请填写产品名称!');history.back(-1);</script>")
response.End
End If
If Request.Form("SortID") = "" And Request.Form("SortPath") = "" Then
response.Write ("<script language='javascript'>alert('请选择所属分类!');history.back(-1);</script>")
response.End
End If
If LTrim(request.Form("ProductModel")) = "" Then
response.Write ("<script language='javascript'>alert('请填写产品型号!');history.back(-1);</script>")
response.End
End If
If (Not IsNumeric(Trim(request.Form("N_Price")))) Or (Not IsNumeric(Trim(request.Form("P_Price"))))Then
response.Write ("<script language='javascript'>alert('请正确填写市场价格、批发价格!');history.back(-1);</script>")
response.End
ElseIf Trim(request.Form("N_Price"))<0 Or Trim(request.Form("P_Price"))<0then
response.Write ("<script language='javascript'>alert('请正确填写市场价格、批发价格!');history.back(-1);</script>")
response.End
End If
If (Not IsNumeric(Trim(request.Form("Stock")))) Then
response.Write ("<script language='javascript'>alert('请填写/选择库存数量!');history.back(-1);</script>")
response.End
End If
If Len(Trim(Request.Form("Unit"))) = 0 Then
response.Write ("<script language='javascript'>alert('请填写/选择产品单位!');history.back(-1);</script>")
response.End
End If
If LTrim(request.Form("Maker")) = "" Then
response.Write ("<script language='javascript'>alert('请填写出品公司!');history.back(-1);</script>")
response.End
End If
If LTrim(request.Form("SmallPic")) = "" Then
response.Write ("<script language='javascript'>alert('请上传产品小图!');history.back(-1);</script>")
response.End
End If
If LTrim(request.Form("BigPic")) = "" Then
response.Write ("<script language='javascript'>alert('请上传产品大图!');history.back(-1);</script>")
response.End
End If
If LTrim(request.Form("Content")) = "" Then
response.Write ("<script language='javascript'>alert('请填写产品详细介绍!');history.back(-1);</script>")
response.End
End If
If Result = "Add" Then
Set rsRepeat = conn.Execute("select ProductNo from Qianbo_Products where ProductNo='" & Trim(Request.Form("ProductNo")) & "'")
If Not (rsRepeat.bof And rsRepeat.EOF) Then
response.Write "<script language='javascript'>alert('" & Trim(Request.Form("ProductNo")) & "产品编号已存在!');history.back(-1);</script>"
response.End
End If
rsRepeat.Close
Set rsRepeat = Nothing
sql = "select * from Qianbo_Products"
rs.Open sql, conn, 1, 3
rs.addnew
rs("ProductName") = Trim(Request.Form("ProductName"))
If Request.Form("ViewFlag") = 1 Then
rs("ViewFlag") = Request.Form("ViewFlag")
Else
rs("ViewFlag") = 0
End If
rs("SortID") = Request.Form("SortID")
rs("SortPath") = Request.Form("SortPath")
rs("ProductNo") = Trim(Request.Form("ProductNo"))
rs("ProductModel") = Trim(Request.Form("ProductModel"))
rs("N_Price") = Round(Trim(Request.Form("N_Price")), 2)
rs("P_Price") = Round(Trim(Request.Form("P_Price")), 2)
rs("Stock") = Round(Trim(Request.Form("Stock")), 2)
rs("Unit") = Trim(Request.Form("Unit"))
rs("Maker") = Trim(Request.Form("Maker"))
If Request.Form("CommendFlag") = 1 Then
rs("CommendFlag") = Request.Form("CommendFlag")
Else
rs("CommendFlag") = 0
End If
If Request.Form("NewFlag") = 1 Then
rs("NewFlag") = Request.Form("NewFlag")
Else
rs("NewFlag") = 0
End If
GroupIdName = Split(Request.Form("GroupID"), "┎╂┚")
rs("GroupID") = GroupIdName(0)
rs("Exclusive") = Trim(Request.Form("Exclusive"))
rs("SmallPic") = Trim(Request.Form("SmallPic"))
rs("BigPic") = Trim(Request.Form("BigPic"))
rs("Content") = RTrim(Request.Form("Content"))
rs("AddTime") = Now()
rs("UpdateTime") = Now()
rs("SeoKeywords") = Trim(Request.Form("SeoKeywords"))
rs("SeoDescription") = Trim(Request.Form("SeoDescription"))
rs.update
rs.Close
Set rs = Nothing
End If
If Result = "Modify" Then
sql = "select * from Qianbo_Products where ID="&ID
rs.Open sql, conn, 1, 3
rs("ProductName") = Trim(Request.Form("ProductName"))
If Request.Form("ViewFlag") = 1 Then
rs("ViewFlag") = Request.Form("ViewFlag")
Else
rs("ViewFlag") = 0
End If
rs("SortID") = Request.Form("SortID")
rs("SortPath") = Request.Form("SortPath")
rs("ProductNo") = Trim(Request.Form("ProductNo"))
rs("ProductModel") = Trim(Request.Form("ProductModel"))
rs("N_Price") = Round(Trim(Request.Form("N_Price")), 2)
rs("P_Price") = Round(Trim(Request.Form("P_Price")), 2)
rs("Stock") = Round(Trim(Request.Form("Stock")), 2)
rs("Unit") = Trim(Request.Form("Unit"))
rs("Maker") = Trim(Request.Form("Maker"))
If Request.Form("CommendFlag") = 1 Then
rs("CommendFlag") = Request.Form("CommendFlag")
Else
rs("CommendFlag") = 0
End If
If Request.Form("NewFlag") = 1 Then
rs("NewFlag") = Request.Form("NewFlag")
Else
rs("NewFlag") = 0
End If
GroupIdName = Split(Request.Form("GroupID"), "┎╂┚")
rs("GroupID") = GroupIdName(0)
rs("Exclusive") = Trim(Request.Form("Exclusive"))
rs("SmallPic") = Trim(Request.Form("SmallPic"))
rs("BigPic") = Trim(Request.Form("BigPic"))
rs("Content") = RTrim(Request.Form("Content"))
rs("UpdateTime") = Now()
rs("SeoKeywords") = Trim(Request.Form("SeoKeywords"))
rs("SeoDescription") = Trim(Request.Form("SeoDescription"))
rs.update
rs.Close
Set rs = Nothing
End If
response.Write "<script language='javascript'>alert('设置成功!');location.replace('ProductList.Asp');</script>"
Else
If Result = "Modify" Then
Set rs = server.CreateObject("adodb.recordset")
sql = "select * from Qianbo_Products where ID="& ID
rs.Open sql, conn, 1, 1
If rs.bof And rs.EOF Then
response.Write ("<center>数据库记录读取错误!</center>")
response.End
End If
ProductName = rs("ProductName")
ViewFlag = rs("ViewFlag")
SortName = SortText(rs("SortID"))
SortID = rs("SortID")
SortPath = rs("SortPath")
ProductNo = rs("ProductNo")
ProductModel = rs("ProductModel")
N_Price = rs("N_Price")
P_Price = rs("P_Price")
Stock = rs("Stock")
Unit = rs("Unit")
Maker = rs("Maker")
CommendFlag = rs("CommendFlag")
NewFlag = rs("NewFlag")
GroupID = rs("GroupID")
Exclusive = rs("Exclusive")
SmallPic = rs("SmallPic")
BigPic = rs("BigPic")
Content = rs("Content")
SeoKeywords = rs("SeoKeywords")
SeoDescription = rs("SeoDescription")
rs.Close
Set rs = Nothing
Else
Randomize Timer
ProductNo = Hour(Now)&Minute(Now)&Second(Now)&"-"&Int(900 * Rnd) + 100
Stock = 10000
End If
End If
End Sub
Sub SelectGroup()
Dim rs, sql
Set rs = server.CreateObject("adodb.recordset")
sql = "select GroupID,GroupName from Qianbo_MemGroup"
rs.Open sql, conn, 1, 1
If rs.bof And rs.EOF Then
response.Write("未设组别")
End If
While Not rs.EOF
response.Write("<option value='"&rs("GroupID")&"┎╂┚"&rs("GroupName")&"'")
If GroupID = rs("GroupID") Then response.Write ("selected")
response.Write(">"&rs("GroupName")&"</option>")
rs.movenext
Wend
rs.Close
Set rs = Nothing
End Sub
Function SortText(ID)
Dim rs, sql
Set rs = server.CreateObject("adodb.recordset")
sql = "Select * From Qianbo_ProductSort where ID="&ID
rs.Open sql, conn, 1, 1
SortText = rs("SortName")
rs.Close
Set rs = Nothing
End Function
%>