| << F.8.2- Common Errors | AppendixF | F.8.4- Sample List 04 - Multiple Selections, Looping the Result >> |
Sample List 01 – Simple List Box
List01Form.htm contains a simple list box:
...
<BODY>
<H3>List 01 Form</H3>
Please click on one selection of music from the Liszt:
<FORM ACTION="List01Response.asp" METHOD=GET>
<SELECT NAME="MusicTitle">
<OPTION>Hunnenschlacht</OPTION>
<OPTION>Malediction</OPTION>
<OPTION>Tannhauser</OPTION>
</SELECT>
<INPUT TYPE="SUBMIT">
</FORM></BODY>
...
|
The result is:
|
|
The response page is List01Response.asp:
...
<BODY>
<H3>List 01 Response</H3>
We will set your background music to
<%
Response.Write Request.QueryString("MusicTitle")
%>
as requested
</BODY>
...
Selecting the option shown in the previous screen shot results in the message:
We will set your background music to Hunnenschlacht as requested
Sample List 02 – Multiple Lists
We can extend the previous example as in List02Form.htm, which contains two separate lists named MusicTitle and MusicDynamic:
...
<BODY>
<H3>List 02 Form - Multiple Lists</H3>
Please click on one selection of music from the Liszt:
<FORM ACTION="List02Response.asp" METHOD=GET>
<SELECT SIZE=3 NAME="MusicTitle">
<OPTION>Hunnenschlacht</OPTION>
<OPTION>Malediction</OPTION>
<OPTION>Tannhauser</OPTION>
<OPTION>Hexamaron</OPTION>
<OPTION SELECTED>Lohengrin</OPTION>
<OPTION>Christus</OPTION>
</SELECT>
<SELECT SIZE=1 NAME="MusicDynamic">
<OPTION SELECTED>Pianissimo</OPTION>
<OPTION>Mezzo</OPTION>
<OPTION>Forte</OPTION>
</SELECT>
<INPUT TYPE="SUBMIT">
</FORM></BODY>
...
|
Note how we specify which option we want to be SELECTED, and how we can control how much of the list is displayed using the SIZE attribute:
|
|
The response page is List02Response.asp:
...
<BODY>
<H3>List 02 Response</H3>
We will set your background music to
<%=Request.QueryString("MusicTitle")%>
performed at
<%=Request.QueryString("MusicDynamic")%>
as requested.
</BODY>
...
|
And the output is as follows (note how values are concatenated in the QueryString):
|
|
Sample List 03 – Multiple Selections, Simple Result
You can enable the user to make multiple selections from a list by including the attribute MULTIPLE in the SELECT tag. The resulting data stream will then consist of all of the choices made concatenated into one data value and separated by &s. This data stream can be used directly, as in the form List03Form.htm:
...
<BODY>
<H3>List 03 Form</H3>
Please select one or more pieces of music from the Liszt:
<FORM ACTION="List03Response.asp" METHOD=GET>
<SELECT SIZE=3 NAME="MusicTitle" MULTIPLE>
<OPTION SELECTED>Hunnenschlacht</OPTION>
<OPTION>Malediction</OPTION>
<OPTION SELECTED >Tannhauser</OPTION>
<OPTION>Hexamaron</OPTION>
<OPTION>Lohengrin</OPTION>
<OPTION>Christus</OPTION>
</SELECT>
<INPUT TYPE="SUBMIT">
</FORM></BODY>
...
The form will look similar to List02Form.htm.
Note that you can highlight multiple choices in the list box by holding down the Ctrl key.
The response page List03Response.asp looks like this:
...
<BODY>
<H3>List 03 Response</H3>
We will set your background
<%
If Request.QueryString("MusicTitle").Count=0 then
Response.Write " to be silent "
ElseIf Request.QueryString("MusicTitle").Count=1 then
Response.Write " music to be "
Response.Write Request.QueryString("MusicTitle")
Else
Response.Write " music to rotate among "
Response.Write Request.QueryString("MusicTitle")
End If
%>
as requested.
</BODY>
...
|
If multiple values are selected, the contents of MusicTitle are written directly from the QueryString:
|
|
| << F.8.2- Common Errors | AppendixF | F.8.4- Sample List 04 - Multiple Selections, Looping the Result >> |

RSS




