View Full Version : Need Help With Dynamic Row

12-14-2006, 12:55 AM

I have some code that allows for the creation of a dynamic row to be added and removed by click of a button. I have set so that you can add only 1 extra row and you can also remove that row, but no more than 1 can be added. The code was working fine and on the page that handles that form I was processing the data and making the necessary entries into the database.

The problem started when I added form validation code. The code is initialized on page load, so I had to add the init function call for the form validation whenever the add row button is clicked. It works fine if it is the first time you tried to submit the form to test for errors. When you click submit again, the browser crashes.

<script type="text/javascript">
function addEvent()
var ni = document.getElementById('myDiv');
var numi = document.getElementById('theValue');
var num = (document.getElementById("theValue").value -1)+ 2;
numi.value = num;
var divIdName = "Account "+num;
var newdiv = document.createElement('div');
newdiv.innerHTML = "<table style=\"WIDTH: 100%\" ....................</table>";
this is the init function for the tmt validator
which is the code in question


function removeEvent(divNum)
var numi = document.getElementById('theValue');
numi.value = 0;
var d = document.getElementById('myDiv');
var olddiv = document.getElementById(divNum);

I am not sure why the browser crashes on the 2nd attempt to press the submit button. It happened every single time i was testing the form validator for catching the errors that it would crash the browser on me.


12-14-2006, 01:49 AM
I actually thought of a better way to word what i was looking for help on.

It seems that when I submit the form, it initializes the tmt validator. How can write the code so that the validator is initialized only once?

12-14-2006, 02:39 AM
Are you using Ajax for the submit? I can't speak for everyone but there isn't enough information here for me to make any assessment.

Maybe you can make a simple test html/javascript file that shows the problem you are having.


12-14-2006, 03:59 AM
What do you need to know in order for me to get some help? I will be happy to provide whatever information necessary to find a solution for this problem.

Thank you in advance

12-14-2006, 05:47 PM
Can you just post a link to the website with the problem? Then explain exactly what is happening that you don't want to happen. Either that or post an html/javascript file that I can run locally that shows the problem.

The problem is, for example, that right now you mention your issue happens when you hit submit. Yet in the code you posted I don't see anything about submit. Is addEvent() called when you click submit?