JavaScripts :: Parsing Form Values
Requirements
The form's method must be set to POST, not GET nor PUT.
Limitations
Microsoft's Internet Explorer 6 and 7 limit the length of URLs to around 2080 characters. Internet Explorer 5 limited them to around 1024 characters. Mozilla Firefox has a much greater limit, we tested up to 6,500 characters with success. As such, this script is ideal for passing variables from one page to the next, or for parsing short forms.
Buy this code with sample forms for just $20
ParserJS is a JavaScript that will read an entire form, append the key/value pairs to a query string, then parse the key values pairs on the next page. The number and type of elements in your form and the data entered, does not matter. All form field types are supported (hidden, select-one, select-multiple, radio, checkbox, text, textarea, file). Lines breaks in textareas, quotes and metacharacters are all preserved and available on the next page. File upload fields show the value entered (file:C:\Documents and Settings\filename.gif), and not the file data.
Form fields do not have to be known or defined, ParserJS parses the entire form and is accessible via an array on the subsequent page.
Some example uses of displaying form data on the subsequent page:
<script>
<!--
if(FORM['age']){
document.write("Your are aged: " + FORM['age']);
}
if(FORM['firstname']){
document.getElementById('nameDiv').innerHTML = FORM['firstname'];
}
if(FORM['lastname']){
document._form.lastname.value = FORM['lastname'];
}
// -->
</script>
|