webForumDet fria alternativet

Kan någon detta !

ASP

5 svar · 314 visningar · startad av ragnared

Medlem sedan apr. 2003152 inlägg
Frågan#1

Kan man lägga till i detta script att när man söker så ska det komma fram max 50 sökord och inte som det gör nu att om man söker på bokstaven (a) så kommer typ 100 stycken fram. kan man begränsa detta det behöver inte kommma i någon speciell ordning.

Så här ser scriptet ut:::

	\<form id=form onSubmit="return form_validator(this)" action="sok.asp?do=sok" method=POST\>

Enter search:
<input type="text" name="searchtext" size="37">  

\<input type="submit" value="- search -"  name="B1"\>

</form>

<%If Request.QueryString("do") = "sok" Then%>

<b>Search results for: <%=Request("SearchText")%></b><br>

<%Const fsoForReading = 1

'###################################################
'-------MAPPEN FILERNA LIGGER I SOM DU SKA SÖKA BLAND------------
'###################################################

Mappen = Server.MapPath("storagearchive")
Mappen = Server.MapPath("uploads")
MappUrl = Mid(Mappen, InStrRev(Mappen, "\") + 1)

strSearchText = Request("SearchText")
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(Mappen)

bolFileFound = False

For Each objFile in objFolder.Files
If Response.IsClientConnected then
If InStr(1,objFile.Name,strSearchText,1) then
Response.Write "<b>»</b> " & objFile.Name & "</a><br>"
bolFileFound = True
End If
End If
Next

if Not bolFileFound then Response.Write "Nothing found..."

Set objFolder = Nothing
Set objFSO = Nothing%>

<%End If%>

Medlem sedan dec. 20003 563 inlägg
#2
Dim i 
i = 0
For Each objFile in objFolder.Files
  If Response.IsClientConnected then
    If InStr(1,objFile.Name,strSearchText,1) then
Response.Write "<b>»</b> " & objFile.Name & "</a><br>"
    bolFileFound = True
    i = i - -1
    if i = 50 then exit for
  End If
End If
Next
Medlem sedan apr. 20031 660 inlägg
#3

HEJ!

Lägg in en räknare som går till 50.

For Each objFile in objFolder.Files AND i < 50

eller

For Each objFile in objFolder.Files
 Do until i > 50
    kod
 i = i + 1
 Loop
Next

Bonus:
Använd [kod]-taggarna!

Medlem sedan dec. 200012 464 inlägg
#4
dim cnt
cnt = 1
For Each objFile in objFolder.Files
     If Response.IsClientConnected then
         If InStr(1,objFile.Name,strSearchText,1) then
             Response.Write "<b>»</b> " & objFile.Name _
          & "</a><br>"
             bolFileFound = True
              if  Cnt = 50 then exit for
             Cnt = Cnt + 1
         End If
    End If
Next
Medlem sedan apr. 2003152 inlägg
#5

Tack snälla ni för hjälpen !!!

Medlem sedan juni 200032 967 inlägg
#6

Det kan vara bra att markera det inlägg som löste problemet för dig. Det blir då lättare för andra att hitta lösning på liknande problem.

275 ms totalt · 4 externa anrop · v20260731065814-full.a51de22e
147 ms — deklarationer (db)
0 ms — hämta statistik (cache)
126 ms — hämta tråd, inlägg och bilagor (db)
147 ms — ändringar (db)