I have a number of textfields that are named description 1, description 2 …description x that are created dynamically 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 verifySave()).
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.
[CODE]
var numItems = 1; // Number of Items on page
var fieldDesNames = new makeArray(‘description 1’); // Array of description textfields
var fieldPnoNames = new makeArray(‘partno 1’); // Array of partno textfields
function addNewItem()
{
// Increase the number of items
numItems++;
// Add the rows to the Inner HTML of our TD
document.getElementById(“textfields”).innerHTML += ‘<B><FONT SIZE=2>Item ‘+numItems+’ <BR></B>DescriptionINPUT TYPE=”text” NAME=”description’+numItems+'” VALUE=””> Part Number <INPUT TYPE=”text” NAME=”partno’+numItems+'” VALUE=”” ONKEYDOWN=”if (event.keyCode==9) { addNewItem(); }”><BR>’;
makeArray(‘description’+numItems+”);
makeArray(‘partno’+numItems+”);
}
function makeArray()
{
this[0] = makeArray.arguments.length;
for (i = 0; i<makeArray.arguments.length; i++)
{
this[i+1] = makeArray.arguments[i];
}
}
function verifySave()
{
msg = confirm(“Are you sure you want to save this data?”)
if (msg)
{
//submitSave();
var e = document.forms[‘genericform’].elements;
for (var i = 0; i<fieldDesNames.length; i++)
{
alert(e[fieldDesNames[i]].value);
}
}
}