unWebify and replaceAll

Demo

Copyright (C)1996 Philip Tan Boon Yew

All Rights Reserved. These functions can be re-used or modified, if credit is given in the source code. I will not be held responsible for any unwanted effects due to the usage of these functions or any derivative. No warrantees for usability for any specific application are given or implied.
Philip Tan, 22nd of April, 1996.

function unWebify(inString)

This function uses replaceAll to convert responses from HTML forms into something more human-readable. It replaces all "+" signs in inString with blank spaces and "&" signs with line breaks. It also uses unescape to get turn escape characters back to normal text. It returns the result as a string.

function replaceAll(sourceString,findString,repString)

This simply replaces all occurrences of findString in sourceString with repString. It returns the result as a string. If it cannot find any instances of findString in sourceString, sourceString will be returned unaltered.

About the functions...

These functions were actually written to help make sense of email replies returned from POST HTML forms, specifically, the 1992 ACS GEP questionnaire. The ideal solution would be to code a CGI-BIN script or program, but for those who do not have the luck to have a CGI-BIN directory, this is a good makeshift solution, especially when you intend to make manual use of the data you receive, anyway.

CAUTION! There may be a bug that does not allow replaceAll to work well with some HTML codes, most notably the Paragraph code. Am looking into it!

Look at the source of this HTML document to get at the code. They are fully annotated and should be easy enough to tailor for your own uses.

Demo

Simply pasting the code into the Input field and clicking "unWebify input" will put the unWebified result into the Output field. Clicking on "Encode input" will put a string in the Output field that has all 'strange' characters from the Input field converted into escape codes. "Find & replace" uses replaceAll to search the Input field for the text in the Find field and replace it with text in the Replace field. "Output to Input" copies the text from the Output field into the Input field.

Input:

Find:

Replace:

Output:

Back to the JavaScript Archives
Copyright © 1996 Philip Tan