I have empno, empname, designation, category, dob.
Category have two option 'S' or 'O'
When I enter empno, empname, designation, category and dob
and when I press enter key all the data remains on the form but only list value is lost. what should I do ? How can I solve this.
Expand|Select|Wrap|Line Numbers
- <%@ Language=VBScript%>
- <%Option Explicit%>
- <html>
- <head>
- <title>Barauni Refinery - Post Retirement Data Management </title>
- </head>
- <%
- Dim R
- Dim R1
- Dim vempno, vempname, vdesign, vcategory
- Dim vdobyyyy, vdobmm, vdobdd
- If Not IsEmpty(Request.Form("submit")) then
- vempno = Request.Form("vempno")
- vempname = Request.Form("vempname")
- vdesign = Request.Form("vdesign")
- vcategory = Request.Form("vcategory")
- vdobyyyy = Request.Form("vdobyyyy")
- vdobmm = Request.Form("vdobmm")
- vdobdd = Request.Form("vdobdd")
- If len(vempno) = 0 then
- errorMsg = "You must enter employee number."
- End If
- If len(errorMsg) = 0 Then
- If len(vempname) = 0 Then
- errorMsg = "Your must enter either employee name."
- Elseif len(vempname) > 20 Then
- errorMsg = "The employee name > 20 characters. Please reduce the size."
- Else
- For i = 1 to len(vempname)
- If instr(1, "_/()[]{}abcdefghijklmnopqrstuvwxyz0123456789 ", mid(vempname, i, 1), vbTextCompare) = 0 then
- errorMsg = "The employee name is invalid. Please re-enter this field."
- Exit For
- End If
- Next
- End If
- End If
- If len(errorMsg) = 0 Then
- conn.Close
- conn.Mode = adModeReadWrite
- conn.Open
- R.Open "Select * from SABF", conn, 2, 3
- R.Addnew
- R("empno") = vempno
- R("empname") = vempname
- R("design") = vdesign
- R("category") = vcategory
- R("dob") = Cdate(vdobmm & "/" & vdobdd & "/" & vdobyyyy)
- R.UPdate
- End If
- End If %>
- <form method="POST" action="sabf.asp">
- <%
- If len(errorMsg) > 0 Then
- Response.Write "<p><font color='red'>" & errorMsg & "</font></p>"
- End If
- %>
- <table width=900>
- <tr>
- <table align="center">
- <tr>
- <td align="center"><font face="arial"><h3>SABF Entry</h3></font></h3>
- </tr>
- </table>
- </tr>
- <tr>
- <table align="center">
- <tr>
- <td align="right"><font face="arial" size=2>Employee No : </font></td>
- <td align='left'><input type="text" style="width:100px" name="vempno" value="<%=vempno%>"></td>
- <td align="right"><font face="arial" size=2>Employee Name : </font></td>
- <td align='left'><input type="text" style="width:300px" name="vempname" value="<%=vempname%>"></td>
- </tr>
- <tr>
- <td align="right"><font face="arial" size=2>Designation : </font></td>
- <td align='left'><input type="text" style="width:200px" name="vdesig"></td>
- <td align="right"><font face="arial" size=2>Category : </font></td>
- <td align="left">
- <font face="arial" size=2><select name="vcategory" value="<%=vcategory%>">
- <option value="O">Officer</option>
- <option value="S" selected>Staff</option></select>
- </font>
- </td>
- </tr>
- <tr>
- <td align="right"><font face="arial" size=2>Date of Birth : </font></td>
- <td>
- <select name="vdobyyyy" value="<%=vdobyyyy%>">
- <%i=1965
- do while i <= 2010
- If i = 2009 Then%>
- <option value="2009" selected>2009</option>
- <%Else%>
- <option value="<%=i%>"><%=i%></option>
- <%End If
- i = i + 1
- loop%>
- </select>
- <select name="vdobmm" value="<%=vdobmm%>">
- <%i=1
- Do while i <= 12
- If i = Cint(vdobmm) then%>
- <option value="<%=vdobmm%>" selected><%=vdobmm%></option>
- <%Else%>
- <option value="<%=i%>"><%=i%></option>
- <%End If
- i = i + 1
- loop%>
- </select>
- <select name="vdobdd" value="<%=vdobdd%>">
- <%If vdobyyyy mod 4 = 0 And vdobmm = 2 Then
- no_of_day = 29
- ElseIf vdobyyyy mod 4 <> 0 and vdobmm = 2 Then
- no_of_day = 28
- ElseIf vdobmm=4 or vdobmm=6 or vdobmm=9 or vdobmm=11 Then
- no_of_day = 30
- Else
- no_of_day = 31
- End If
- i=1
- Do while i <= no_of_day
- If i = Cint(vdobdd) Then%>
- <option value="<%=vdobdd%>" selected><%=vdobdd%></option>
- <%Else%>
- <option value="<%=i%>"><%=i%></option>
- <%End If
- i = i + 1
- loop%>
- </select><font color='blue' size=2>(yyyy-mm-dd)</font>
- </td>
- </tr>
- <tr>
- <table align="center">
- <tr>
- <td align="center"><input type="Submit" name="submit" value="Save">
- <input type="reset" name="reset" value="Reset">
- </td>
- </tr>
- </table>
- </tr>
- </table>
- </form>
- </body>
- </html>