/    Sign up×
Community /Pin to ProfileBookmark

Java variables calculation on change (Excel replica)

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,

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @sim_singh spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...