Solved

Keeping added table rows on page return.

Posted on 2011-03-02
1
236 Views
Last Modified: 2012-05-11
I’m using this little Jscript I found to add rows to a form table. I’m using classic asp on this page and when I have a return on the page (error or whatever), it resets back to default with only one row. Is there a way using this code to keep the number rows on a page return? Thanks for your help///
<script type="text/JavaScript">
	function addRow(r){
		var root = r.parentNode;//the root
		var allRows = root.getElementsByTagName('tr');//the rows' collection
		if(allRows.length<10) {
			var cRow = allRows[0].cloneNode(true)//the clone of the 1st row
			var cInp = cRow.getElementsByTagName('input');//the inputs' collection of the 1st row
			
			for(var i=0;i<cInp.length;i++){//changes the inputs' names (indexes the names)
				cInp[i].setAttribute('name',cInp[i].getAttribute('name')+'_'+(allRows.length+1))
			}
			root.appendChild(cRow);//appends the cloned row as a new row
		}
		else {
			alert("Only 5 rows allowed");
		}
	}
</script>

Open in new window

0
Comment
Question by:inrworx
1 Comment
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 35024260
either you have to save the table row to cookie or save it on the server, so that at next page load, you can fetch that new row
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Fine Tune your automatic Updates for Ubuntu / Debian
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now