Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

I need help doing some of the math and displaying the results the way i need it to look

Avatar

Level 1

I need help doing some of the math and displaying the results the way i need it to look. I'm not sure how to do this math in JavaScript. Also I don't know how to display the correct number for the given result. I need the form to do two math problems (shown below) and then take the two answers and determine what number (in .50" increments) is in between the two answers. The number cant be less then the lowest number or higher then the highest number. I know this sounds a little strange but can someone please look at the attached form and help me figure this out? Thanks.

I need the math as follows:

M1-L1-58.32-18.15-.5 then M1-L1-58.32-18.15-1

then take the sum from each and find the nearest .5 inch.

i.e. 96-13-58.32-18.15-.5 = 6.03

      96-13-58.32-18.15-1 = 5.53

So the nearest .5 inch of the two would be 6.00

Depending on what the nearest .5 inch of the two,

display the following in the Spacer Tube Part Number:

5 Replies

Avatar

Former Community Member

M1-L1-58.32-18.15-.5 then M1-L1-58.32-18.15-1

huh?

can you explain the calculation again please

Avatar

Level 1

Look at the attached form. I need to find the nearest half inch after performing two equations. It's a little hard to explain. M1 and L1 are fields on the form. When the user enters the M1 and L1 information, i need the form to do the math twice.

Once like this: M1 - L1 - 58.32 - 18.15 - .5

And then like this: M1 - L1 - 58.32 - 18.15 - 1

Take the two answers and find the nearest half inch

Than answer must be between the two number in half inch

increments.

Avatar

Former Community Member

what i would do is create a hidden text box, where i would save the results from the first equestion.

then compare the results of the second, with the number of the hidden textbox

rounding with javascript: http://wsabstract.com/javatutors/round.shtml

Avatar

Level 1

Ok, I did that but now my only problem is I cant really be rounding the numbers. I need the one even half inch in between the two numbers. If I use JavaScript it will just round up or down right? I need what’s in the middle. I think in Excel this is called “Floor”. Can JavaScript use the “Floor” method? See http://www.techonthenet.com/excel/formulas/floor.php