Jump to content

Dynamic Add Row Script Dieing at 9 rows????


cmaclennan

Recommended Posts

Hey Guys,

 

I have a script that allows for additional rows to be added to a form i have if needed but i have just noticed that when i get upto and above 10 rows it stops working and just submits the first 9 rows again. Any help is greatly appreciated as i need to get this fixed as soon as humanly possible.

 

<script language="javascript">
		//add a row to the rows collection and get a reference to the newly added row
			var partsRowCount = 1; //stores the number of rows

		//add a new row to the table
		function addRow()
		{
			var namePrefix = "_" + (+partsRowCount + 1); //setup the prefix variable

			partsRowCount++; //increment the counter

			//add a row to the rows collection and get a reference to the newly added row
			var newRow = document.all("orderentry").insertRow();

			//add 3 cells (<td>) to the new row and set the innerHTML to contain text boxes

			var oCell = newRow.insertCell();
			oCell.innerHTML = "<input type='text' name='partid" + namePrefix + "'>";

			oCell = newRow.insertCell();
			oCell.innerHTML = "<input type='text' name='quantity" + namePrefix + "'>";

			oCell = newRow.insertCell();
			oCell.innerHTML = "<input type='text' name='desc" + namePrefix + "'>";

			oCell = newRow.insertCell();
			oCell.innerHTML = "<input type='text' name='serial" + namePrefix + "'>";			
		}

		//deletes the specified row from the table
		function removeRow(src)
		{
			/* src refers to the input button that was clicked.	
			   to get a reference to the containing <tr> element,
			   get the parent of the parent (in this case case <tr>)
			*/			
			var oRow = src.parentElement.parentElement;		

			//once the row reference is obtained, delete it passing in its rowIndex			
			document.all("orderentry").deleteRow(oRow.rowIndex);		
		}

	</script>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.