I have a number of textfields that are named description 1, description 2 ...description 5 and a button named 'Save'. The user needs to input values into each one of these textfields. What I need to do is extract the value of each textfield once the user hits the 'Save' button (function onSave()). I have the following code, but i can't seem to get anything in my variable string to alert back to me. Could someone please take a look. var fieldNames = new makeArray(' description 1 ', 'description 2', ''description 3, 'description 4', 'description 5' ); function makeArray() { this[0] = makeArray.arguments.length; for (i = 0; i<makeArray.arguments.length; i++) this[i+1] = makeArray.arguments[i]; } function onSave() { var desValues = ''; for (var i = 0; i<numItems; i++) { desValues += document.genericform.elements[fieldDesNames[i]].value + ' '; alert(desValues[0]); } } Code (markup):
1. Why do you alert(desValues[0]) and not just alert(desValues)? This variable is a string. not an array. 2. Are you sure your field names contain spaces?