Avian Gamers Network

Forum
It is currently Sat May 03, 2025 11:01 pm

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sat May 07, 2005 10:58 pm 
Offline
User avatar

Joined: Wed Feb 11, 2004 10:59 am
Posts: 586
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.

note: ignore the name attribute currently on the TD tags. I put them on there while I was trying to figure out why it wasnt naming the INPUT tags correctly...

Javascript to replicate the fields:
Code:
<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:
Code:
<table width="100%" border="0" id="HAWBtbl">
<tr style="display: none" id="addHAWB">
<td width="25%" name="frmDispatchHAWB_">
<input SIZE="20" name="frmDispatchHAWB" maxlength="20" onKeyDown="if(event.keyCode==13) event.keyCode=9;" autocomplete="off">
</td>
<td width="25%" name="frmDispatchMove_">
<input SIZE="15" name="frmDispatchMove" maxlength="40" onKeyDown="if(event.keyCode==13) event.keyCode=9;" autocomplete="off">
</td>
<td width="25%" name="frmDispatchBoL_">
<input SIZE="20" name="frmDispatchBoL" maxlength="40" onKeyDown="if(event.keyCode==13) event.keyCode=9;" autocomplete="off">
</td>
<td width="25%" name="frmDispatchAWB_">
<input SIZE="10" name="frmDispatchAWB" maxlength="40" onKeyDown="if(event.keyCode==13) event.keyCode=9;" autocomplete="off">
</td>
</tr>
<tr id="ShowAdditionalHAWB"></tr>
</table>
<table width="100%" border="0">
<tr>
<td colspan="4">
<div align="right"><input type="button" value="Additional Bills" onClick="AdditionalHAWB()"> </div>
</td>
</tr>
</table>


Thanks in advance for whatever help you all can give me....


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 08, 2005 11:48 am 
Offline
Spammer
User avatar

Joined: Tue Mar 25, 2003 4:10 pm
Posts: 3574
Location: Fairfax, Virginia
Hmmm...

In this line:
newField[i].name = theName + counter;

Have you tried setting it to:
newField[i].name.value = theName + counter;

Or, Setting the ID as in:
newField[i].id = theName + counter;

If not, you might try poking around www.javascript.com or looke in the JavaScript core guide at: http://javascript.internet.com/tutorial ... deJS15.zip

_________________
--The Hermit


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group