a,making it work (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


TheMythe -> a,making it work (11/24/2005 10:10:17)

Hiya,

I got this page to update records.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Update een record</title>
</head>
<body background="Deventer2004.jpg" bgproperties="fixed"
onFocus="window.status='Stavoor'"
onBlur="window.status='Stavoor'" &>
<!-- #include file="connection_modulair.asp" -->
<%
'create and open the recordset object
apparatuurtype = "SELECT DISTINCT apptype FROM sbapparatuurtypen"
locatie = "SELECT DISTINCT locatie FROM sblocaties"
status = "SELECT DISTINCT status FROM sbstatus"
garantie_termijn = "SELECT DISTINCT [Garantietermijn (mnd)] FROM sbgarantietermijn"
rsCommon.Open "sbapparatuur", adoCon, 1, 3, 2
rsCommon2.open apparatuurtype, adoCon, 1, 3, adCmdText
rsCommon3.open locatie, adoCon, 1, 3, adCmdText 
rsCommon4.open status, adoCon, 1, 3, adCmdText
rsCommon5.open garantie_termijn, adoCon, 1, 3, adCmdText %>

<% if not isEmpty(Request.QueryString) then recno = Request.QueryString("recno") 
if recno="" then %>
   <h5>Selecteer een Record</h5>
   <table width=95% cellspacing=1 cellpadding=5 border=1 bordercolorlight="#FFFF00" bordercolordark="#808000" bgcolor="#000000">
   <!-- begin column headers -->
   <tr>
      <th><font color="#FFFF00"><b><span style="text-transform: uppercase">ID</span></b></font></th>
      <th><font color="#FFFF00"><b><span style="text-transform: uppercase">Type ID</span></b></font></th>
      <th><font color="#FFFF00"><b><span style="text-transform: uppercase">Stavoor ID</span></b></font></th>
      <th><font color="#FFFF00"><b><span style="text-transform: uppercase">Aanschaf datum</span></b></font></th>
      <th><font color="#FFFF00"><b><span style="text-transform: uppercase">In gebruik datum</span></b></font></th>
      <th><font color="#FFFF00"><b><span style="text-transform: uppercase">Hoofdgebruiker</span></b></font></th>
      <th><font color="#FFFF00"><b><span style="text-transform: uppercase">Locatie</span></b></font></th>
      <th><font color="#FFFF00"><b><span style="text-transform: uppercase">History</span></b></font></th>
      <th><font color="#FFFF00"><b><span style="text-transform: uppercase">Laatste update</span></b></font></th>
      <th><font color="#FFFF00"><b><span style="text-transform: uppercase">Serienummer</span></b></font></th>
      <th><font color="#FFFF00"><b><span style="text-transform: uppercase">Kamer</span></b></font></th>
      <th><font color="#FFFF00"><b><span style="text-transform: uppercase">Publiekelijk</span></b></font></th>
      <th><font color="#FFFF00"><b><span style="text-transform: uppercase">Status</span></b></font></th>
      <th><font color="#FFFF00"><b><span style="text-transform: uppercase">Aanschafprijs</span></b></font></th>
      <th><font color="#FFFF00"><b><span style="text-transform: uppercase">Garantietermijn</span></b></font></th></tr>

   <% 'cycle through the record set and display each row results
   recno = 1
   do until rsCommon.EOF %>
   <tr>
      <% if rsCommon("id")>=0 then %>
      <td><a href="update_apparaten.asp?recno=<%=recno%>"><font color="#FFFF00"><b><span style="text-transform: uppercase"><%= rsCommon("id")%></span></b></font></a></td>
      <% else %>
      <td><font color="#FFFF00"><b><span style="text-transform: uppercase"><%= rsCommon("id")%></span></b></font></td>
      <% end if %>
      <td><font color="#FFFF00"><b><span style="text-transform: uppercase"><%= rsCommon("type_id")%></span></b></font></td>
      <td><font color="#FFFF00"><b><span style="text-transform: uppercase"><%= rsCommon("stavoor_id")%></span></b></font></td>
      <td><font color="#FFFF00"><b><span style="text-transform: uppercase"><%= rsCommon("aanschaf_datum")%></span></b></font></td>
      <td><font color="#FFFF00"><b><span style="text-transform: uppercase"><%= rsCommon("ingebruik_datum")%></span></b></font></td>
      <td><font color="#FFFF00"><b><span style="text-transform: uppercase"><%= rsCommon("reguliere_gebruiker")%></span></b></font></td>
      <td><font color="#FFFF00"><b><span style="text-transform: uppercase"><%= rsCommon("locatie_id")%></span></b></font></td>
      <td><font color="#FFFF00"><b><span style="text-transform: uppercase"><%= rsCommon("history")%></span></b></font></td>
      <td><font color="#FFFF00"><b><span style="text-transform: uppercase"><%= rsCommon("last_update")%></span></b></font></td>
      <td><font color="#FFFF00"><b><span style="text-transform: uppercase"><%= rsCommon("serienummer")%></span></b></font></td>
      <td><font color="#FFFF00"><b><span style="text-transform: uppercase"><%= rsCommon("kamer")%></span></b></font></td>
      <td><font color="#FFFF00"><b><span style="text-transform: uppercase"><%= rsCommon("is_publiek")%></span></b></font></td>
      <td><font color="#FFFF00"><b><span style="text-transform: uppercase"><%= rsCommon("status_id")%></span></b></font></td>
      <td><font color="#FFFF00"><b><span style="text-transform: uppercase"><%= rsCommon("aanschafprijs")%></span></b></font></td>
      <td><font color="#FFFF00"><b><span style="text-transform: uppercase"><%= rsCommon("garantie_termijn")%></span></b></font></td></tr>


   <!-- next Row = next Record -->
   <% 'increment record position with MoveNext method
   rsCommon.MoveNext
   recno = recno+1
   loop 
   'close record set and flush object from memory
   rsCommon.Close
   set rsCommon = Nothing
   %>
   </table>
   <% if rowCount>8 then %>
<p><a href="#">Naar boven</a></p>
   <% else %>
      <% end if
else
   'move pointer to selected record
   recno = Request.Querystring("recno")-1
   rsCommon.MoveFirst
   rsCommon.Move recno
   
   if isEmpty(Request.Form) then %>
<h5>Om veranderingen op te slaan in de database, druk op Update.</h5>
      <form method="post" onsubmit="return validateForm(this)">
      <table width=95% cellspacing=1 cellpadding=3 border=0>
      <col width=40% align="right">
      <col width=60%>
      <tr>
 <form method="post"> 
         <td>Type:</td>
         <td><select name="type_id">
  <% do until rsCommon2.EOF %>
   <option><%= rsCommon2("apptype")%>
   <% rsCommon2.MoveNext
     loop
      rsCommon2.Close 
      set rsCommon2 = Nothing %> 
      </select></td>
      <tr>
         <td>Type:</td>
         <td><input maxlength=254 name='Type' value="<%= rsCommon("type_id")%>"></td></tr>
      <tr>
         <td>Stavoor ID:</td>
         <td><input maxlength=254 name='Stavoor_ID' value="<%= rsCommon("stavoor_id")%>"></td></tr>
      <tr>
         <td>Aanschaf datum:</td>
         <td><input maxlength=254 name='Aanschaf datum' value="<%= rsCommon("aanschaf_datum")%>"></td></tr>
      <tr>
         <td>In gebruikname:</td>
         <td><input maxlength=254 name='In gebruik' value="<%= rsCommon("ingebruik_datum")%>"></td></tr>
      <tr>
         <td>Hoofdgebruiker:</td>
         <td><input maxlength=254 name='Hoofdgebruiker' value="<%= rsCommon("reguliere_gebruiker")%>"></td></tr>
      <tr>
         <td>Locatie:</td>
         <td><select name="locatie_id">
  <% do until rsCommon3.EOF %>
   <option><%= rsCommon3("locatie")%>
   <% rsCommon3.MoveNext
     loop
      rsCommon3.Close 
      set rsCommon3 = Nothing %> 
      </select></td>
      <tr>
         <td>History:</td>
         <td><input maxlength=254 name='History' value="<%= rsCommon("history")%>"></td></tr>
      <tr>
         <td>Laatste update:</td>
         <td><input maxlength=254 name='Laatste update' value="<%= rsCommon("last_update")%>"></td></tr>
      <tr>
         <td>Serienummer:</td>
         <td><input maxlength=254 name='Serienummer' value="<%= rsCommon("serienummer")%>"></td></tr>
      <tr>
         <td>Kamer:</td>
         <td><input maxlength=254 name='Kamer' value="<%= rsCommon("kamer")%>"></td></tr>
      <tr>
         <td>Publiekelijk:</td>
         <td><input maxlength=254 name='Publiekekijk' value="<%= rsCommon("is_publiek")%>"></td></tr>
      <tr>
         <td>Status:</td>
         <td><select name="status_id">
  <% do until rsCommon4.EOF %>
   <option><%= rsCommon4("status")%>
   <% rsCommon4.MoveNext
     loop
      rsCommon4.Close 
      set rsCommon4 = Nothing %> 
      </select></td>
      <tr>
         <td>Aanschafprijs:</td>
         <td><input maxlength=254 name='Aanschafprijs' value="<%= rsCommon("aanschafprijs")%>"></td></tr>
      <tr>
         <td>Garantie termijn in maanden:</td>
         <td><select name="garantie_termijn">
  <% do until rsCommon5.EOF %>
   <option><%= rsCommon5("Garantietermijn (mnd)")%>
   <% rsCommon5.MoveNext
     loop
      rsCommon5.Close 
      set rsCommon5 = Nothing %> 
      </select></td>
      </table>
      <p><input type="submit" value="Update"> <input type="reset" value="annuleren" onclick="self.location.replace('update_apparaten.asp')"></p>
   </form>
   <% else
      ' store db field names in fldsArray
      fldsArray = array ("type_id", "stavoor_id", "aanschaf_datum", "ingebruik_datum", "reguliere_gebruiker", "locatie_id", "history", "last_update", "serienummer", "kamer", "is_publiek", "status_id", "aanschafprijs", "garantie_termijn")

      ' store form field values into valsArray
      valsArray = array (Request.Form("type_id"),Request.Form("stavoor_id"),Request.Form("aanschaf_datum"),Request.Form("ingebruik_datum"),Request.Form("reguliere_gebruiker"),Request.Form("locatie_id"),Request.Form("history"),Request.Form("last_update"),Request.Form("serienummer"),Request.Form("kamer"),Request.Form("is_publiek"),Request.Form("status_id"),Request.Form("aanschafprijs"),Request.Form("garantie_termijn"))
   
      ' update the Recordset
      rsCommon.Update fldsArray, valsArray %>
   
<h5>Dit record is ge-update.</h5>
      <table width=90% cellspacing=1 cellpadding=5 border=1 bordercolorlight="#FFFF00" bordercolordark="#808000" bgcolor="#000000">
      <col width=35% align="right">
      <% for each field in rsCommon.Fields %>
      <tr>
         <td><font color="#FFFF00"><b><span style="text-transform: uppercase"><%= field.Name %></span></b></font></td>
         <td><font color="#FFFF00"><b><span style="text-transform: uppercase"><%= field.Value %></span></b></font></td></tr>
      <% next %>
      </table>
      
      <form method="post">
      <input type="button" value="Update een ander record." onclick="self.location.replace('update_apparaten.asp')">
      </form>

   <% end if
   'close record set and flush object from memory
   rsCommon.Close
   set rsCommon = Nothing
   adoCon.close
   set adoCon = Nothing
   end if %>
</body>
</html>


However, I'm still not able to make the whole thing work. For instanc4e: I'm unsure how to put the pulldownmenu's into a variasble that can be implementred into a 'valsareray' field. If i know that then I also know how to put the pulldownmenu.value into a variable which can be implemented into that 'valsarra' field. Ok, I realise that I should have written this down in reversed order, first I need to know how to put thje variable of the pulldownlist into a variable and then put that variable in the correct spot into the 'valsarray' field so that it will update the correct 'table.record'
Those are just 2 o the things I still need to figure out on this page and I got several of these update pages.
I also would like to be able to have all the field values correctly with currency and date and time etc, how? Is it even possible that if there is no valid option in the pulldownbmenu, that I can add a new value. I realise that there must be already a value there in that list...lets say i choose: 'add new value' then a new field appears after it where I can add a new value to that same pulldownlist, is that possible since it is already linked to a table...




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.0625