It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Javascript calculating dynamic form

Javascript calculating dynamic form

Postby PastTense on Tue Sep 20, 2011 8:25 am

Hi there,

First post here so nice to meet you all.

I am trying to build a calculate feature into a dynamic form. So basically the function should calculate a value that the user would enter into a field multiplied by a number that comes out of a recordset. It should then be able to give the sum of all the totals as a grand total.

IE - x = number entered into a field by a user
y = number that originates from a recordset
z = x * y
total = sum of all z

So the javascript would look something like this

function calculate() {

x = eval(document.form1.x.value)
y = eval(document.form1.y.value)
z = (x * y)
document.form1.z.value = z

Total = Total + z
}

Here is the catch, since the form is dynamically created I don't know how many times the script needs to run.

I also would need to introduce a variable so that im left with x(i) instead of just x etc etc..

My main concern is how do I make the script loop the correct number of times.

any help would be great, thanks!
PastTense
 
Posts: 1
Joined: Tue Sep 20, 2011 8:11 am

Who is online

Users browsing this forum: No registered users and 8 guests