Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java variables calculation on change (Excel replica)

Status
Not open for further replies.

simasi

Programmer
Oct 1, 2009
20
0
0
US
I have a excel sheet that I need to replicate in JSP (using struts 1 framework). Now everything is done but I am stuck at the calculation part. As you might have seen in excel, some columns are calculations based on other columns.
So if I change field 'a', 'd' field should change automatically based on its formula (let's say, d=a*1.1 +b*2.1).

Now I tried to use the funstion in javascript where I read 'a' and 'b' values from JSP, then I calculate and everything works fine. But when I try to assign the calculation result for field 'd' in JSP throush javascript, 'd' does not change.

function adjustCalcs ()
{


var a = eval("document.form.al.value");
var b = eval("document.form.b.value");
var dCalc = ((a * 1.05) + (b * 1.1));


document.form.d.value = dCalc ; (this is where it should change the value of field 'd' in JSP, but ti won't...donno why?)


}

Or is there any better way to do these dynamic changes in JSP? Would appreciate the insight.

Thanks,
 
Thanks ..but result still the same :( new values are not coming to the script.
 
May be caching issue? stale data or something?
 
I really doubt that. Is it possible for you to post your entire JSP code?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top