| Jeg er ved at lave en søgemaskine i Access og ASP til en online videokæde
 som studieprojekt.
 Søgningen fungerer fint med i det tilfælde hvor brugeren har valgt film og
 trykker på reservationsknappen skal siden skifte til et opsummerende vindue
 hvor brugeren skal indtaste login og password hvor der skal bekræftiges af
 brugeren og en e-mail skal sendes automatisk til virksomheden. Hvorfor
 virker denne del ikke.
 
 Her er hele programmet. Hjælp søges hurtigt.
 
 <% Option Explicit %>
 <% '*** ^^^ - ALWAYS start with Option Explicit! This will require that you
 Dim all
 '*** your variables which is sometimes damn annoying, but this really
 helps you
 '*** once you get a lot of variables. Trust me on this one ;)
 %>
 <%'-- Doc type: Not really that important... %>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 <HTML>
 <HEAD>
 <%' Content type: Not really that important either... %>
 <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=ISO-8859-1">
 <title>Søgemaskine</title>
 <%' Use stylesheets - Makes life so much easier when you want to change the
 colour of ALL your text %>
 <style type="text/css">
 <!--
 body, td, p
 {
 font-family: Verdana, Arial, Helvetica, Sans-Serif;
 font-size: 12px;
 font-weight: Normal;
 color: #333333;
 SCROLLBAR-FACE-COLOR: #003366;
 SCROLLBAR-HIGHLIGHT-COLOR: #CCCCCC;
 SCROLLBAR-SHADOW-COLOR: #CCCCCC;
 SCROLLBAR-3DLIGHT-COLOR: #000000;
 SCROLLBAR-ARROW-COLOR: #CCCCCC;
 SCROLLBAR-TRACK-COLOR: #CCCCCC;
 SCROLLBAR-DARKSHADOW-COLOR: #000000;
 }
 
 .header2
 {
 font-family: Verdana, Arial, Helvetica, Sans-Serif;
 font-size: 14px;
 font-weight: Bold;
 color: #333333;
 }
 
 .error
 {
 font-family: Verdana, Arial, Helvetica, Sans-Serif;
 font-size: 12px;
 font-weight: Bold;
 color: #FF0000;
 }
 
 input, select, textarea
 {
 font-family: Verdana, Arial, Helvetica, Sans-Serif;
 font-size: 11px;
 font-weight: Normal;
 background-color:#FFFFFF;
 }
 
 .button
 {
 width: 80px;
 font-family: Verdana, Arial, Helvetica, Sans-Serif;
 font-size: 11px;
 font-weight: Normal;
 background-color:#FFFFFF;
 }
 -->
 </style>
 </HEAD>
 <BODY>
 
 <form id="formSearch" method="post" action="film-rh.asp">
 <input type="hidden" name="xmode" value="search">
 
 <table cellspacing="0" cellpadding="0" border="0">
 <tr>
 <td>Søgeord:</td>
 <td><input type="text" name="film" size="20"
 value="<%=Request.Form("film")%>"></td>
 </tr>
 <tr>
 <td> </td>
 <%' A button! - well lets use class="button" to get the style we
 specified in <style> %>
 <td><input class="button" type="submit" name="submit" value="Søg"></td>
 </tr>
 </table>
 
 <%
 '*** Test if we are in reserve mode ***
 If Request.Form("xmode") = "reserve" Then
 Dim Item
 
 '*** Pull out reserved movies ***
 For Each Item In Request.Form
 If Left(Item,3) = "chk" Then
 Response.Write "<p>Du har nu reserveret film nummer " &
 Request.Form(Item) & ".</p>"
 End If
 Next
 
 ElseIf Request.Form("film") <> "" then
 Dim intHits
 '*** If we have some input, search for it - no more than 100 hits though
 ***
 intHits = DoMovieSearch(Request.Form("film"), 100)
 End if
 
 If intHits > 0 Then %>
 <BR>
 
 <table cellspacing="0" cellpadding="0" border="0">
 <tr>
 <td> </td>
 <td>
 <input class="button" type="button" name="btnReserver" value="Reserver"
 onClick="javascript:onReserve()">
 </td>
 </tr>
 </table>
 
 <script type="text/javascript">
 function onReserve()
 {
 document.formSearch.xmode.value = 'reserve';
 document.formSearch.submit();
 }
 </script>
 
 <BR>
 <BR>
 
 <p>Antal hits: <%=intHits%></p>
 
 <% End If %>
 
 <%' Make sure the form tag is ended AFTER your last <input> tag %>
 </form>
 
 </BODY>
 </HTML>
 
 <%
 '/**
 '* Use functions. Very nice if you might want to include the search
 '* feature more than one place on the web-site. This function returns
 '* the number of hits.
 '* strKeywords is the what to search the DB for, intMaxHits is the maximum
 '* number of hits you want printed.
 '**/
 Function DoMovieSearch(strKeywords, intMaxHits)
 '*** Always remember to Dim your variables ***
 Dim DB, DBSti, SQL, rs, Genre, skuespillere, Pris, Antal, Status
 
 DoMovieSearch = 0
 Set DB = Server.CreateObject("ADODB.Connection")
 DBSti = "DBQ=" & Server.Mappath("film.mdb")
 DB.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & DBSti
 
 '*** You might want to check strKeyword for wierd stuff like ', \, ) - SQL
 might not like it ***
 SQL = "select * from film where Genre like '%" & strKeywords & "%' or
 Titel like '%" & strKeywords & "%' or Skuespillere like '%" & strKeywords &
 "%'"
 
 Set rs = DB.Execute(SQL)
 If not rs.eof then
 '*** Use & _ if you want to continue a string on the next line. vbCrLf
 will do line return ***
 Response.Write "<table cellspacing=""0"" cellpadding=""0"" border=""0"">"
 & vbCrLf & "<tr>" & vbCrLf & _
 "<td class=""header2"">Vælg</td>" & vbCrLf & _
 "<td class=""header2"">Titel</td><td class=""header2""
 width=30> </td>" & vbCrLf & _
 "<td class=""header2"">Genre</td><td class=""header2""
 width=30> </td>" & vbCrLf & _
 "<td class=""header2"">Skuespillere</td><td class=""header2""
 width=30> </td>" & vbCrLf & _
 "<td class=""header2"">Pris i dkr.</td><td class=""header2""
 width=30> </td>" & vbCrLf & _
 "<td class=""header2"">Antal</td><td class=""header2""
 width=30> </td>" & vbCrLf & _
 "<td class=""header2"">Ledige</td><td class=""header2""
 width=30> </td>" & vbCrLf & _
 "</tr>" & vbCrLf
 Do until rs.eof
 '*** Only print if have not yet reached our limit ***
 If DoMovieSearch < intMaxHits Then
 '*** If the movies have an unique ID use that for the checkbox name ***
 Genre = rs("Genre")
 Skuespillere = rs("Skuespillere")
 Pris = rs("Pris")
 Antal = rs("Antal")
 Status = rs("Status")
 Response.Write "<tr>" & vbCrLf & _
 "<td><input type=""checkbox"" value=""val"" name=""chk" &
 DoMovieSearch & """></td>" & vbCrLf & _
 "<td>" & rs("Titel") & "</td><td width=30> </td>" & vbCrLf
 & _
 "<td>" & Genre & "</td><td width=30> </td>" & vbCrLf & _
 "<td>" & Skuespillere & "</td><td width=30> </td>" &
 vbCrLf & _
 "<td>" & Pris & "</td><td width=30> </td>" & vbCrLf & _
 "<td>" & Antal & "</td><td width=30> </td>" & vbCrLf & _
 "<td>" & Status & "</td><td width=30> </td>" & vbCrLf & _
 "</tr>"  & vbCrLf
 End If
 '*** Inc the number of hits in the return variable ***
 DoMovieSearch = DoMovieSearch + 1
 rs.movenext
 Loop
 
 Response.Write "</table>" & vbCrLf
 Else
 Response.Write "<p class=""error"">Der var ingen film, der matchede din
 søgekriterier!</p>"
 End If
 
 
 '*** Do some cleaning up ***
 Set rs = Nothing
 DB.Close
 Set DB = Nothing
 End Function
 
 
 
 
 
 |