Recommended: How to solve the problem of left intercepting character titles with different lengths We often see that when we use left to cut strings, because Chinese characters and English coexist in the title, the two news titles are different in length. In order to solve this problem, we can use the following function. % '****************************************** 'Function name: gotTopic 'Function: cut off string, one Chinese character is calculated
Users often encounter some unexpected situations when submitting forms, such as refreshing the page multiple times, pressing the back key, etc. If control measures are not taken, it will cause the problem of repeated submission of the form.The prevention method introduced in this article is mainly composed of four subroutines. In relatively simple applications, you just need to place these codes in the inclusion file and directly quote them; for those more complex environments, we give some improvement suggestions at the end of the article.
1. Basic work process
Next, we discuss these four subroutines in turn.
(I) Initialization
Here we want to save two variables in the Session object, among which:
⑴ Each form corresponds to a unique identifier called FID, and a counter is used to make this value unique.
⑵ Whenever a form is successfully submitted, its FID must be stored in a Dictionary object.
We use a dedicated process to initialize the above data. Although each subroutine will call it in the future, it will actually only be executed once during each session:
SubInitializeFID()
IfNotIsObject(Session(FIDList)) Then
SetSession(FIDList)=Server.CreateObject(Scripting.Dictionary)
Session(FID)=0
EndIf
EndSub
(II) Unique identifier for generating form
The following function GenerateFID() is used to generate a unique flag for the form. The function first adds the FID value by 1 and then returns it:
FunctionGenerateFID()
InitializeFID
Session(FID)=Session(FID)+1
GenerateFID=Session(FID)
EndFunction
(III) Register Submitted Form
When the form is submitted successfully, its unique identifier is registered in the Dictionary object:
SubRegisterFID()
DimstrFID
InitializeFID
strFID=Request(FID)
Session(FIDlist).AddstrFID,now()
EndSub
(IV) Check whether the form is submitted repeatedly
Before formally processing a form submitted by the user, you should check whether its FID is registered in the Dictionary object. The following CheckFID() function is used to complete this work. If it has been registered, it returns FALSE, otherwise it returns TRUE:
FunctionCheckFID()
DimstrFID
InitializeFID
strFID=Request(FID)
CheckFID=notSession(FIDlist).Exists(strFID)
EndFunction
Share: Interpret the use of asp to write code similar to search engine functions First, build an access database. There is a URLINDEX table in the library, where the URL and Keywords fields are indexed respectively, as follows: URL text (index: with (no duplication)) Title text Description text Summary text Keywords text (index: with (no duplication)) Program file doquery.asp, code: HTMLHEADTITLE simple search engine
2 pages in total Previous page 12 Next page