if boligtype <> "ALLE" then boligtypeSQL = "boligtype = '" & boligtype & "' and " whereSQL = true end if
if region <> "ALLE" then regionSQL = "region = '" & region & "' and " whereSQL = true end if
if sovepladser <> "ALLE" then sovepladserSQL = "sovepladser = '" & sovepladser & "' and " whereSQL = true end if
if vaerelser <> "ALLE" then vaerelserSQL = "vaerelser = '" & vaerelser & "' and " whereSQL = true end if
strSQL = "SELECT * FROM boliger" if whereSQL then strSQL = strSQL & " WHERE " strSQL = strSQL & boligtypeSQL & regionSQL & sovepladserSQL & vaerelserSQL
if right(strSQL,4) = "and " then strSQL = left(strSQL,len(strSQL)-5)
strSQL = strSQL & " ORDER BY by"
end if %>
<form method="POST" action="default.asp?page=soegbolig&mode=search"> <table border="0" width="100%" cellspacing="0" cellpadding="5"> <tr> <td width="16%">Boligtype:</td> <td width="84%"><select size="1" name="boligtype" class="boxInput"> <option value="ALLE">ALLE</option> <option <% if boligtype = "Sommerhus" then %>selected<% end if %>>Sommerhus</option> <option <% if boligtype = "Lejlighed" then %>selected<% end if %>>Lejlighed</option> <option <% if boligtype = "Båd" then %>selected<% end if %>>Båd</option> <option <% if boligtype = "Campingvogn" then %>selected<% end if %>>Campingvogn</option> </select></td> </tr> <tr> <td width="16%">Region:</td> <td width="84%"><select size="1" name="region" class="boxInput"> <option value="ALLE">ALLE</option> <option <% if region = "Nord Jylland" then %>selected<% end if %>>Nord Jylland</option> <option <% if region = "Midt Jylland" then %>selected<% end if %>>Midt Jylland</option> <option <% if region = "Sønder Jylland" then %>selected<% end if %>>Sønder Jylland</option> <option <% if region = "Fyn" then %>selected<% end if %>>Fyn</option> <option <% if region = "Nord Sjælland" then %>selected<% end if %>>Nord Sjælland</option> <option <% if region = "Syd Sjælland" then %>selected<% end if %>>Syd Sjælland</option> <option <% if region = "Lolland/Falster" then %>selected<% end if %>>Lolland/Falster</option> <option <% if region = "Bornholm" then %>selected<% end if %>>Bornholm</option> </select></td> </tr> <tr> <td width="16%">Sovepladser:</td> <td width="84%"><select size="1" name="sovepladser" class="boxInput"> <option value="ALLE">ALLE</option> <option <% if sovepladser = "1" then %>selected<% end if %>>1</option> <option <% if sovepladser = "2" then %>selected<% end if %>>2</option> <option <% if sovepladser = "3" then %>selected<% end if %>>3</option> <option <% if sovepladser = "4" then %>selected<% end if %>>4</option> <option <% if sovepladser = "5" then %>selected<% end if %>>5</option> <option <% if sovepladser = "6" then %>selected<% end if %>>6</option> <option <% if sovepladser = "7" then %>selected<% end if %>>7</option> <option <% if sovepladser = "8" then %>selected<% end if %>>8</option> <option <% if sovepladser = "9" then %>selected<% end if %>>9</option> <option <% if sovepladser = "10" then %>selected<% end if %>>10</option> <option <% if sovepladser = "11" then %>selected<% end if %>>11</option> <option <% if sovepladser = "12" then %>selected<% end if %>>12</option> <option <% if sovepladser = "Flere end 12" then %>selected<% end if %>>Flere end 12</option> </select></td> </tr> <tr> <td width="16%">Værelser:</td> <td width="84%"><select size="1" name="vaerelser" class="boxInput"> <option value="ALLE">ALLE</option> <option <% if vaerelser = "1-5" then %>selected<% end if %>>1-5</option> <option <% if vaerelser = "6 eller der over" then %>selected<% end if %>>6 eller der over</option> </select></td> </tr> </table> <p><input type="submit" value="SØG" name="B1" class="boxSubmit"></p> </form>
I dette særtema ser vi på, hvordan cloud og AI bliver fundamentet for virksomhedernes digitale forretning, og hvordan de nye muligheder for automatisering og forretningsværdi kan udnyttes uden at miste overblik, sikkerhed og menneskelig kontrol.
Her er lidt kode som jeg fandt for nogleår siden, rettet ind til mp.mdb og forespørgslen alfalokaler:
'All rights reserved - Ebberup.dk 2001 - please leave the copyright note here 'and you can use this script as freeware dim antal antal = 0 'Open connection set ani = Server.CreateObject("ADODB.Recordset") 'Modify and use this connection if your database is in your database directory 'ani.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=D:\your database directory\items.mdb" ani.Open "Alfalokaler", "DBQ=" & Server.Mappath("mp.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};"
Do While not ani.EOF antal = antal + 1 ani.MoveNext Loop ani.Close set ani = Nothing
Jeg er ikke helt med, tænker du på select skal laves ud fra en tabel i databasen?
<td width="84%"><select size="1" name="boligtype" class="boxInput"> <option value="ALLE">ALLE</option> <option <% if boligtype = "Sommerhus" then %>selected<% end if %>>Sommerhus</option> <option <% if boligtype = "Lejlighed" then %>selected<% end if %>>Lejlighed</option> <option <% if boligtype = "Båd" then %>selected<% end if %>>Båd</option> <option <% if boligtype = "Campingvogn" then %>selected<% end if %>>Campingvogn</option> </select></td>
eller sakl SQL rettes til at hente navnet på bolig typen fra en anden tabel?
Jeg har selv prøvet med denne opsætning, og det virker også ok. i dropdown menuen, men der kommer ikke noget resultat når jeg søger?
<td width="84%"><select size="1" name="boligtype" class="boxInput"> <option value="ALLE">ALLE</option> <% strSQL = "SELECT * FROM boligtyper ORDER BY boligtype" Set rs = Server.CreateObject("ADODB.RecordSet") rs.Open strSQL, strDSN, 1, 1 Do While Not rs.EOF %>
<option value="<%=rs("boligtype")%>" <% if boligtype = rs("boligtype") then %>selected<% end if %>><%=rs("boligtype")%>
<% rs.MoveNext loop rs.Close Set rs = Nothing %> </select></td>
Det var vist noget værre rod og så manglede der noget. Her har jeg klippet i en fil jeg selv bruger til samme formål og det virker. Du skal blot ændre i linierne 8, 17 og 37. De to førte er navnet på din databasefil og den sidste er form action.
'All rights reserved - Ebberup.dk 2001 - please leave the copyright note here 'and you can use this script as freeware dim antal antal = 0 'Open connection set ani = Server.CreateObject("ADODB.Recordset") 'Modify and use this connection if your database is in your database directory ani.Open "boligtyper", "DBQ=" & Server.Mappath("mp.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};"
Do While not ani.EOF antal = antal + 1 ani.MoveNext Loop ani.Close set ani = Nothing set ani = Server.CreateObject("ADODB.Recordset") ani.Open "boligtyper", "DBQ=" & Server.Mappath("mp.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};" %> <HEAD> <meta name="Generator" content="Stone's WebWriter 4" /> <SCRIPT TYPE="text/javascript"> function focus() { Valg.boligtype.focus() } </SCRIPT> <!-- Minus AutoDato --> <LINK REL="stylesheet" HREF="kauv.css" TYPE="text/css"> </HEAD> <BODY onload="focus()"> <BR><BR><BR> <TABLE WIDTH="300" BORDER="0" ALIGN="center"> <TR VALIGN="top" ALIGN="center"> <TD ALIGN="center"> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">Vælg boligtype:</font><BR><BR></TD></tr><tr ALIGN="center"> <TD ALIGN="center"> <FORM ACTION="Hvorskalvihendu.asp" METHOD="POST" NAME="Valg"> <select name="boligtype"> <% Do While not ani.EOF %> <% if ani("boligtype") = "Alle" then %> <option selected value="<%=ani("boligtype")%>"> <%=ani("boligtype")%></option> <% huske = ani("boligtype") else %> <option value="<%=ani("boligtype")%>"> <%=ani("boligtype")%></option> <% End if %> <% ani.MoveNext Loop ani.Close set ani = Nothing %> </select></TD></tr><tr ALIGN="left"> <TD ALIGN="center"><BR><INPUT TYPE="submit" VALUE="OK" NAME="Videre"> </TD></TR></TABLE></FORM> </body></html>
oskar>> Det ser ud til at virke, men hvad er denne del? - og er den nødvendig?
'All rights reserved - Ebberup.dk 2001 - please leave the copyright note here 'and you can use this script as freeware dim antal antal = 0 'Open connection set ani = Server.CreateObject("ADODB.Recordset") 'Modify and use this connection if your database is in your database directory ani.Open "boligtyper", "DBQ=" & Server.Mappath("mp.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};"
Do While not ani.EOF antal = antal + 1 ani.MoveNext Loop ani.Close
Den tæller hvor mange poster der er i feltet, men hvorfor aner jeg ikke. Jeg har ikke prøvet at fjerne den. Som du kan je er det ikke mig der har lavet koden, jeg har bare sakset den.
Linien <% huske = ani("boligtype") kan du osse slette.
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.