By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,508 Members | 1,915 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,508 IT Pros & Developers. It's quick & easy.

Value of list is lost when form is submitted

vikas251074
100+
P: 198
I am using Oracle 9i and ASP

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
  1. <%@ Language=VBScript%>
  2. <%Option Explicit%>
  3. <html>
  4. <head>
  5. <title>Barauni Refinery - Post Retirement Data Management </title>
  6. </head>
  7. <%
  8. Dim R
  9. Dim R1 
  10. Dim vempno, vempname, vdesign, vcategory
  11. Dim vdobyyyy, vdobmm, vdobdd
  12.   If Not IsEmpty(Request.Form("submit")) then
  13.     vempno = Request.Form("vempno")
  14.     vempname = Request.Form("vempname")
  15.     vdesign = Request.Form("vdesign")
  16.     vcategory = Request.Form("vcategory")
  17.     vdobyyyy = Request.Form("vdobyyyy")
  18.     vdobmm = Request.Form("vdobmm")
  19.     vdobdd = Request.Form("vdobdd")
  20.     If len(vempno) = 0 then
  21.       errorMsg = "You must enter employee number."
  22.     End If
  23.     If len(errorMsg) = 0 Then
  24.       If len(vempname) = 0 Then
  25.         errorMsg = "Your must enter either employee name."
  26.       Elseif len(vempname) > 20 Then
  27.         errorMsg = "The employee name > 20 characters. Please reduce the size."
  28.       Else
  29.         For i = 1 to len(vempname)
  30.           If instr(1, "_/()[]{}abcdefghijklmnopqrstuvwxyz0123456789 ", mid(vempname, i, 1), vbTextCompare) = 0 then
  31.             errorMsg = "The employee name is invalid. Please re-enter this field."
  32.             Exit For
  33.           End If
  34.         Next
  35.       End If
  36.     End If
  37.     If len(errorMsg) = 0 Then
  38.       conn.Close
  39.       conn.Mode = adModeReadWrite
  40.       conn.Open
  41.       R.Open "Select * from SABF", conn, 2, 3
  42.       R.Addnew
  43.       R("empno") = vempno
  44.       R("empname") = vempname
  45.       R("design") = vdesign
  46.       R("category") = vcategory
  47.       R("dob") = Cdate(vdobmm & "/" & vdobdd & "/" & vdobyyyy)
  48.       R.UPdate
  49.     End If
  50.   End If %>
  51.     <form method="POST" action="sabf.asp">
  52. <%
  53.       If len(errorMsg) > 0 Then
  54.         Response.Write "<p><font color='red'>" & errorMsg & "</font></p>"
  55.       End If
  56. %>
  57.  
  58.       <table width=900>
  59.         <tr>
  60.           <table align="center">
  61.             <tr>
  62.               <td align="center"><font face="arial"><h3>SABF Entry</h3></font></h3>
  63.             </tr>
  64.  
  65.           </table>
  66.         </tr>
  67.         <tr>
  68.           <table align="center">
  69.             <tr>
  70.               <td align="right"><font face="arial" size=2>Employee No : </font></td>
  71.               <td align='left'><input type="text" style="width:100px" name="vempno" value="<%=vempno%>"></td>
  72.               <td align="right"><font face="arial" size=2>Employee Name : </font></td>
  73.               <td align='left'><input type="text" style="width:300px" name="vempname" value="<%=vempname%>"></td>
  74.             </tr>
  75.             <tr>
  76.               <td align="right"><font face="arial" size=2>Designation : </font></td>
  77.               <td align='left'><input type="text" style="width:200px" name="vdesig"></td>
  78.               <td align="right"><font face="arial" size=2>Category : </font></td>
  79.               <td align="left">
  80.                  <font face="arial" size=2><select name="vcategory" value="<%=vcategory%>">
  81.                        <option value="O">Officer</option>
  82.                        <option value="S" selected>Staff</option></select>
  83.                  </font>
  84.               </td>
  85.             </tr>
  86.             <tr>
  87.               <td align="right"><font face="arial" size=2>Date of Birth : </font></td>
  88.               <td>
  89.                 <select name="vdobyyyy" value="<%=vdobyyyy%>">
  90.                   <%i=1965
  91.                   do while i <= 2010
  92.                     If i = 2009 Then%>
  93.                       <option value="2009" selected>2009</option>
  94.                     <%Else%>
  95.                         <option value="<%=i%>"><%=i%></option>
  96.                     <%End If
  97.                     i = i + 1
  98.                   loop%>
  99.                 </select>
  100.                 <select name="vdobmm" value="<%=vdobmm%>">
  101.                   <%i=1
  102.                   Do while i <= 12
  103.                     If i = Cint(vdobmm) then%>
  104.                       <option value="<%=vdobmm%>" selected><%=vdobmm%></option>
  105.                     <%Else%>
  106.                       <option value="<%=i%>"><%=i%></option>
  107.                     <%End If
  108.                     i = i + 1
  109.                   loop%>
  110.                 </select>
  111.                 <select name="vdobdd" value="<%=vdobdd%>">
  112.                   <%If vdobyyyy mod 4 = 0 And vdobmm = 2 Then
  113.                     no_of_day = 29
  114.                   ElseIf vdobyyyy mod 4 <> 0 and vdobmm = 2 Then
  115.                     no_of_day = 28
  116.                   ElseIf vdobmm=4 or vdobmm=6 or vdobmm=9 or vdobmm=11 Then
  117.                     no_of_day = 30
  118.                   Else
  119.                     no_of_day = 31
  120.                   End If
  121.                   i=1
  122.                   Do while i <= no_of_day
  123.                     If i = Cint(vdobdd) Then%>
  124.                       <option value="<%=vdobdd%>" selected><%=vdobdd%></option>
  125.                     <%Else%>
  126.                       <option value="<%=i%>"><%=i%></option>
  127.                     <%End If
  128.                     i = i + 1
  129.                   loop%>
  130.                 </select><font color='blue' size=2>(yyyy-mm-dd)</font>
  131.               </td>
  132.             </tr>
  133.         <tr>
  134.           <table align="center">
  135.             <tr>
  136.               <td align="center"><input type="Submit" name="submit" value="Save">
  137.                                  <input type="reset" name="reset" value="Reset">
  138.               </td>
  139.             </tr>
  140.           </table>
  141.         </tr>
  142.       </table>
  143.     </form>
  144. </body>
  145. </html>
  146.  
Oct 21 '09 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.