Gossamer Forum
Home : General : Perl Programming :

Calculating fields

Quote Reply
Calculating fields
Hi,

I'd like to do some calculations with input fields before processing a form (cgi) script, but I'm thinking it might have to be done with javascript?? Anyway, here's the scenario......

Ok, I have a total of four drop down menus (with pre-determined numeric values), with an empty text box in-between the first two and one after the second two.

drop down menu 1
value="10" option 1
value="20" option 2

drop down menu 2
value="25" option 1
value="50" option 2

input txt box which is empty (amount 1)

-------a link/button here which will say calculate menu 1 and 2

drop down menu 3
option 1
option 2

drop down menu 4
option 1
option 2

input txt box which is empty (amount 2)

-------a link/button here which will say calculate menu 3 and 4

an empty txt box for the total amount of both txt box fields above

++++++ a link button here which will say calculate both (amount 1 + amount 2)

now, after clicking the link/button above the value will be placed into an input txt box below here which will total the two values above.

so to sum up what I'm trying to do is this:

A user makes a selection from the first two drop down menus, let's say he chooses option 1 and option 1. He then hits the link/button (which says calculate) and the two values are multiplied giving him a value of 250 in the first text box. He then does the same thing (for demonstration purposes let's say the values are the same) on the second set of drop down menus. So he now has two text fields filled in with the value 250. After he hits the final link/button which says calculate both, the final value will be added to the last text box....so it would be a calculation of value 1 + value 2 = 500.

Ok..it made sense when I was typing it..but it might be confusing when reading it. Like I said I think it might need to be done with javascript....but I'm not sure if I'm better off going with a totally different system. Before I start trying to figure out a solution in javascript, I'd like to get some other ideas and suggestions on how to approach this. BTW- I've thought about just using a shopping cart, but it won't work with the rest of the system. Any input is appreciated.

Thanks

Quote Reply
Re: Calculating fields In reply to
 
Yeppers, That's javascript if you don't want to leave to page and get the calculation instantly, what you want to do is steal someone else's he he, Really, At giggo.com the have loan calculators, they do what you want, just save their page with the calculator you like, and strip the page to bear minimun, and then modify the fields the java calculates, You should have no problem. But if you'd rather check out the calculators at javascript.com then they could be modified also.

Since I don't know java script that's all I can recomend. :)

perlkid

Quote Reply
Re: Calculating fields In reply to
Lol... I hear ya...cool, I'll go check it out and see what I can come up with. Actually, looks like they've done something similar!! Thanks for the tip perlkid, I appreciate it.

Quote Reply
Re: Calculating fields In reply to
 
No Problem :)