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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom Calculation Script code is WRONG!

Status
Not open for further replies.

Rainman1234

Programmer
Nov 9, 2004
15
US
I am somewhat a newbie when it comes to Adobe Acrobat 5.0. Right now I am trying to make it possible to fill out an OSHA 300 Form on the intranet for my company. I “TRYING” to be nice for my co-workers. I want them to enter the numbers and the form to do the math for them. At column M there are 6 choices (injury, skin disorder, respiratory condition, posioning, hearing, all other illnesses). There are 13 lines per page. I made the 6 choices a check box all named the same. After all you are only allowed 1 choice. In the code you see below I named them line1M through line13M. Here is my problem. At the bottom they want a total for the columns checked. I made the columns exports value 1 through 6. 1 for injury 6 for all other illnesses. I have been trying to properly code the Custom Calculation Script. Below is my code so far... (I know its wrong I just don’t know why! Any and all help is appreciated.)


function calculate(injury) {
var injury = getField("TotalM1");
var skin = getField("TotalM2");
var respiratory = getField("TotalM3");
var poisoning = getField("TotalM4");
var hearing = getField("TotalM5");
var allOther = getField("TotalM5");

var line1M = getField("line1M");
var line2M = getField("line2M");
var line3M = getField("line3M");
var line4M = getField("line4M");
var line5M = getField("line5M");
var line6M = getField("line6M");
var line7M = getField("line7M");
var line8M = getField("line8M");
var line9M = getField("line9M");
var line10M = getField("line10M");
var line11M = getField("line11M");
var line12M = getField("line12M");
var line13M = getField("line13M");

if (line1M.value = 1) {
injury.value = injury.value + 1}
if (line2M.value = 1) {
injury.value = injury.value + 1 }
if (line3M.value = 1) {
injury.value = injury.value + 1}
if (line4M.value = 1) {
injury.value = injury.value + 1 }
if (line5M.value = 1) {
injury.value = injury.value + 1 }
if (line6M.value = 1){
injury.value = injury.value + 1 }
if (line7M.value = 1){
injury.value = injury.value + 1 }
if (line8M.value = 1) {
injury.value = injury.value + 1 }
if (line9M.value = 1) {
injury.value = injury.value + 1 }
if (line10M.value = 1) {
injury.value = injury.value + 1 }
if (line11M.value = 1) {
injury.value = injury.value + 1 }
if (line12M.value = 1) {
injury.value = injury.value + 1 }
if (line13M.value = 1) {
injury.value = injury.value + 1 }

}
 
Try:
if(oneValue == anotherValue) {
...
...
}

checking for equality requires two equal signs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top