See the following example. Program :
Displaybooks. asp
<% @ Language = JavaScript %>
<HTML>
<Body>
<Form method = post>
Book category; <% = getbookslistbox () %>
<P>
<Input type = submit>
<%
Function getbookslistbox ()
{
Bookslistbox = Application ("bookslistbox ")
If (bookslistbox! = NULL) return bookslistbox;
CRLF = string. fromcharcode (13, 10)
Bookslistbox = "<select name = books>" + CRLF;
SQL = "select * From books order by name ";
Cnnbooks = server. Createobject ("ADODB. Connection ");
Cnnbooks. Open ("books", "admin ","");
Rstbooks = cnnbooks. Execute (SQL );
Fldbookname = rstbooks ("bookname ");
While (! Rstbooks. EOF ){
Bookslistbox = bookslistbox + "<option>" +
Fldbookname + "" + CRLF;
Rstbooks. movenext ();
}
Bookslistbox = bookslistbox + ""
Application ("bookslistbox") = bookslistbox
'Note that the essence of application technology should be
Return bookslistbox;
}
%>