| << F.11.2- Common Errors | AppendixF | F.12.0- Multiple Forms on One Page >> |
Sample TextArea Parsing
In this example, TextArea01Form.htm, we ask for some comments on an order.
...
<BODY>
<H3>TextArea 01 Form</H3>
<FORM ACTION="TextArea01Response.asp" METHOD=GET>
(Dummy data to make parsing example more illustrative)<BR>
Please enter your name<INPUT NAME=NameUser><BR><BR>
Please enter your comments in this Text Area:<BR>
<TextArea NAME="ta" COLS=30 ROWS = 4></TextArea><BR><BR>
(Dummy data to make parsing example more illustrative)<BR>
Please enter your Start Date<INPUT NAME=DateStart>
<BR><INPUT TYPE="SUBMIT" VALUE="Submit Query">
</FORM></BODY>
...
|
The comments will be read by a shipping clerk, so we want them to be formatted with line breaks as created when the visitor struck the Enter key when filling in the form.
|
|
The code TextArea01Response.asp uses the following variables:
|
varStringEntire |
String |
Includes all the data from all the fields |
|
varStart |
Number |
Location of the first character of the text area field |
|
varEnd |
Number |
Location of first ampersand after the text area field |
|
varTA |
String |
Includes only data from the text area field |
|
iCharCounter |
Number |
As the loop steps through each character, this variable keeps track of the number of the character we are now examining |
|
varTAFormatted |
String |
Same as varTA but with spaces instead of plus signs and <BR> tags instead of %0D%0A codes |
For help in your understanding of the code, we've included (but changed to remarks) two lines which write intermediate constructions to the page.
...
<BODY>
<H3>TextArea 01 Response</H3>
<HR>Here is the data as one item from the collection:<BR>
<%=Request.QueryString("ta")%>
<HR>Here is the data parsed by hand from the entire string<BR>
<%
varStringEntire = Request.QueryString
'Response.Write "varStringEntire = " & varStringEntire & "<BR><BR>"
varStart = instr(varStringEntire,"ta=") + 3
varEnd = instr(varStart,varStringEntire,"&")-1
varTA = mid(varStringEntire,varstart,varEnd-VarStart+1)
'Response.Write "varTA = " & varTA & "<BR><BR>"
Dim varTAFormatted
iCharCounter = 1
Do While iCharCounter<=Len(varTA)
If mid(varTA,iCharCounter,6) = "%0D%0A" Then
varTAFormatted = varTAFormatted & "<br>"
iCharCounter = iCharCounter + 6
ElseIf mid(varTA,iCharCounter,1) = "+" then
varTAFormatted = varTAFormatted & " "
iCharCounter = iCharCounter + 1
Else
varTAFormatted = varTAFormatted & mid(varTA,iCharCounter,1)
iCharCounter = iCharCounter + 1
End If
Loop
Response.Write varTAFormatted
%>
</BODY>
...
Note how in the entire QueryString:
- Words are separated by plus signs
- Lines are separated by %0D%0A (escape character) codes
|
However in the parsed data values of the collection:
|
|
| << F.11.2- Common Errors | AppendixF | F.12.0- Multiple Forms on One Page >> |

RSS


