Log in

View Full Version : Help with a dynamic table/calculator



hammerstein
12-08-2009, 05:38 AM
I want to add something simple to my friends' site but know only a little bit of js.

What I want to work off of, is a dynamic table with 3 rows of 4 columns.
Column A would be a number entered by the user.
Column B would be - / + or * function entered by the user.
Column C would be another number entered by the user.
Column D would be the total.
Example : 5 + 25 = 30

Also I saw a page once where you could click a button and it added a new row of columns to a table like the one I want to work on and another button to remove it.

I've been reading and working on figuring this out but my js skills go as far as basic forms and not much with dynamic stuff.

Thanks in advance.

hammerstein
12-09-2009, 05:50 AM
anyone?

bluewalrus
12-09-2009, 06:17 AM
seems like you're going at this backwards. http://www.javascriptkit.com/script/cut18.shtml

if not can u provide example of what you're trying to do?

hammerstein
12-09-2009, 03:12 PM
Thanks , I found something online that I'd like to have and once it's working I could modify it to my needs :
----------------------------------
The table should have three rows as pictured to start.
Each row has a Value A, Value B, and Operation textbox.
After each one has been changed, validate it.
I want to make sure that only numbers are allowed in the Value fields
Only +, -, /, and * allowed in Operation field.
After each one has been changed, calculate the total for that row and for the whole spreadsheet.
If a row’s total is negative, color the box red.
If a row’s total is positive, color the box green.
When the user presses the “Add New Calculation” button, add a new row above the last row (total).
When the user presses the “Remove Last Row” button, remove the last row.
Do not let the user remove all the rows, always keep one calculation row and the total row.
Update the totals after each add/remove.

http://www.gunvids.com/addons/albums/images/383397075.jpg

Once it's like that above. I will add personalization and more stuff, but I just can't figure out the code for it. :confused: