Receiving Form Data

This demo page retrieves the data that you entered in the demo_form1.htm file. Form names and values are extracting from the URL for this page using the property and the slice() method. The + symbol in the field values (used to represent a blank space) is replaced with a blank space. Finally, the text string is split into individual field names and values using the split() method. The following function is run when the page is loaded by the browser:

function retrieveData() {
   searchString =;
   searchString = unescape(searchString);
   formString = searchString.replace(/\+/g, " ");
   data = formString.split(/[&=]/g);[1];
1) Your name is
2) Your age is
3) Your city of residence is
Carey, P. New Perspectives on JavaScript, Course Technology: Boston, 2005.