I have a set of dynamic form fields in a table that I need to have shown and perhaps repeated depending on how many times the button is clicked. I have the script to do it and it works except the form fields are not renamed with the counter appended on the end. It renames the TD tag names instead of the INPUT tag name attribute.
Javascript to replicate the fields:
<script language="JavaScript">
var counter = 0;
function AdditionalHAWB()
{
counter++;
var newFields = document.getElementById('AddHAWB').cloneNode(true);
newFields.id = '';
newFields.style.display = 'block';
var newField = newFields.childNodes;
for (var i=0;i<newField.length;i++)
{
var theName = newField[i].name
if (theName)
newField[i].name = theName + counter;
alert (theName + counter);
}
var insertHere = document.getElementById('ShowAdditionalHAWB');
insertHere.parentNode.insertBefore(newFields,insertHere);
}
</script>
Hidden Section that is unhidden and is repeated:
"<table width=""100%"" border=""0"" id=""HAWBtbl"">" & vbNewLine & _
"<tr style=""display: none"" id=""addHAWB"">" & vbNewLine & _
"<td width=""25%"" name=""frmDispatchHAWB_"">" & vbNewLine & _
"<input SIZE=""20"" name=""frmDispatchHAWB"" maxlength=""20"" " & EnterToTab & " autocomplete=""off"">" & vbNewLine & _
"</td>" & vbNewLine & _
"<td width=""25%"" name=""frmDispatchMove_"">" & vbNewLine & _
"<input SIZE=""15"" name=""frmDispatchMove"" maxlength=""40"" " & EnterToTab & " autocomplete=""off"">" & vbNewLine & _
"</td>" & vbNewLine & _
"<td width=""25%"" name=""frmDispatchBoL_"">" & vbNewLine & _
"<input SIZE=""20"" name=""frmDispatchBoL"" maxlength=""40"" " & EnterToTab & " autocomplete=""off"">" & vbNewLine & _
"</td>" & vbNewLine & _
"<td width=""25%"" name=""frmDispatchAWB_"">" & vbNewLine & _
"<input SIZE=""10"" name=""frmDispatchAWB"" maxlength=""40"" " & EnterToTab & " autocomplete=""off"">" & vbNewLine & _
"</td>" & vbNewLine & _
"</tr>" & vbNewLine & _
"<tr id=""ShowAdditionalHAWB""></tr>" & vbNewLine & _
"</table>" & vbNewLine & _
"<table width=""100%"" border=""0"">" & vbNewLine & _
"<tr>" & vbNewLine & _
"<td colspan=""4"">" & vbNewLine & _
"<div align=""right""><input type=""button"" value=""Additional Bills"" onClick=""AdditionalHAWB()""> </div>" & vbNewLine & _
"</td>" & vbNewLine & _
"</tr>" & vbNewLine & _
"</table>" & vbNewLine & _
Thanks in advance for whatever help you all can give me....