Help with simple JS to add cells then multiply the total by a %

this is not my expertise at all, but I’m creating an Adobe fillable form and need to calculate 4 cells then multiply that total by 75%. Help! I have not clue where to even start

  1. Retrieve the values of the four cells: You would need to assign the values of the four cells to variables in JavaScript. If the cells are form fields, you could retrieve their values using the document.getElementById method and store them in variables.
var cell1 = parseInt(document.getElementById("cell1").value);
var cell2 = parseInt(document.getElementById("cell2").value);
var cell3 = parseInt(document.getElementById("cell3").value);
var cell4 = parseInt(document.getElementById("cell4").value);
  1. Add the values of the four cells: Once you have the values of the four cells, you can add them together to get the total.
var total = cell1 + cell2 + cell3 + cell4;
  1. Multiply the total by 75%: To calculate the result of multiplying the total by 75%, you would simply multiply the total by 0.75.
var result = total * 0.75;
  1. Display the result: Finally, you would need to display the result of the calculation. You could do this by updating the value of an element on your page, such as a div or a form field.
document.getElementById("result").innerHTML = result;

Here is the full code to perform the calculations:

// retrieve the values of the four cells and store them in variables
var cell1 = parseInt(document.getElementById("cell1").value);
var cell2 = parseInt(document.getElementById("cell2").value);
var cell3 = parseInt(document.getElementById("cell3").value);
var cell4 = parseInt(document.getElementById("cell4").value);

// add the values of the four cells to get the total
var total = cell1 + cell2 + cell3 + cell4;

// multiply the total by 0.75 to get the result
var result = total * 0.75;

// display the result on the page
document.getElementById("result").innerHTML = result;

You would need to replace “cell1”, “cell2”, “cell3”, “cell4”, and “result” with the actual id’s of the form fields in your Adobe fillable form.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.