Page

F.8.3- Sample List 01 - Simple List Box

Created by Brendan Doss.
Last Updated by Brendan Doss.  

PublicCategorized as Appendix F.

Not yet tagged
<< F.8.2- Common ErrorsAppendixFF.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:

 

Appendixf_image016

 

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:

 

Appendixf_image017

 

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):

 

Appendixf_image018

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:

 

Appendixf_image019

<< F.8.2- Common ErrorsAppendixFF.8.4- Sample List 04 - Multiple Selections, Looping the Result >>

Copyright © 2003 by Wiley Publishing, Inc.

Powered by Near-TimeTerms of Services | Privacy Policy | Security Policy |