Page

F.8.5- Sample List 06 - Parsing From Complex Choices

Created by Brendan Doss.
Last Updated by Brendan Doss.  

PublicCategorized as Appendix F.

Not yet tagged
<< F.8.4- Simple List 04 - Multiple Selections, Looping the Result AppendixF F.9.0- Password Fields >>

Sample List 06 – Parsing From Complex Choices

One frequently asked question is how to use only part of the data that is shown in a list box: for example, you could show information in a list box such as first and last name, telephone extensions and department, but only want to use part of that data, say the telephone number. In a browser this is not as easy to do as in, for example, Access, where multiple columns are allowed in list boxes. However you can build complex choices and then parse out the data of interest, as demonstrated in this example, and using techniques from the chapter on VBScript techniques. 

 

Our form, List06Form.htm, has options containing several pieces of information:

 

...

<BODY>

<H3>List 06 Form</H3>

Please click on one selection of music from the Liszt:

<FORM ACTION="List06Response.asp" METHOD=GET>

<SELECT NAME="MusicTitle">

<OPTION>Hunnenschlacht - 1856 - Symphonic poem</OPTION>

<OPTION>Malediction - 1842 - Piano & Orch.</OPTION>

<OPTION>Tannhauser - 1864 - Piano Transcription</OPTION>

</SELECT>

<INPUT TYPE="SUBMIT">

</FORM></BODY>

...

 

The file List06Response.asp parses this information and prints it in a readable form:

 

...

<BODY>

<H3>List 06 Response</H3>

We will set your background music to

<%

varRaw = Request.QueryString("MusicTitle")

varLocDashOne = instr(varRaw,"-")

varLocDashTwo = instr(varLocDashOne+1,varRaw,"-")

varTitle = left(varRaw,varLocDashOne-1)

Response.Write varTitle

%>

<BR>A piece from

<%

varDate = mid(varRaw,varLocDashOne+2,4)

Response.Write varDate

%>

<BR>Written by Liszt as a

<%

varGenre = mid(varRaw,varLocDashTwo+2)

Response.Write varGenre

%>

</BODY>

...

 

Note how the white space appears in the QueryString:

 

Appendixf_image021

<< F.8.4- Simple List 04 - Multiple Selections, Looping the Result AppendixF F.9.0- Password Fields >>

Copyright © 2003 by Wiley Publishing, Inc.

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