Home
 
The page you are viewing is part of our 160,000 page PDF discussion forum archive spanning 1999-2011.
Go to the new Planet PDF forum to join the PDF community.
 

Search
 Advanced   
Sign up for a WebBoard account Archive Forum Home


PLATINUM
SPONSOR

GOLD
SPONSORS



Topic  
Go to previous topicPrev TopicGo to next topicNext Topic
Author Message
alocke
alocke

Total Messages 5

Subject:values for checkboxes

I am new to java script. I am attempting a form in which each checkbox has a different value. At the end of the form, the boxes checked will be added for a total. How can I do this?


Posted: 05 Apr 2011 10:34 AM
Left Button SpacerView user's profile profileRight Button Spacer
 
 
gkaiseril
gkaiseril

Total Messages 3000

Subject:values for checkboxes

You can use the calculation option 'the field is the ____ of fields:' and select the check boxes to be summed.

You can enter the check boxes names in the simplified field notation as long as their names comply with the naming restriction of that option. Field names must start with a an alphabetic character and spaces or dots need to be preceded by the JavaScript escape character, "\".

Or write a custom calculation script to loop through the fields and exclude any fields with a value of 'Off' from your calculation.

George Kaiser


Posted: 05 Apr 2011 01:34 PM
Originally Posted: 05 Apr 2011 01:33 PM
Left Button SpacerView user's profile profileRight Button Spacer
 
 
alocke
alocke

Total Messages 5

Subject:values for checkboxes

If I were to write a custom calculation, what would it be?


Posted: 06 Apr 2011 10:48 AM
Left Button SpacerView user's profile profileRight Button Spacer
 
 
gkaiseril
gkaiseril

Total Messages 3000

Subject:values for checkboxes

Pretty hard to do without the field names, since Acrobat JavaScript is an object orientated language, and form fields are a type of object.

// document level function or placed in custom calculation script
function Sum (aFields) {
var nSum = 0;
var sValue = '';
for(i = 0; i < aFields.length; i++) {
sValue = this.getField(aFields[i]).valueAsString;
if(!isNaN(sValue) & sValue != "") {
nSum += Number(sValue);
} // end if number or not null
} // end for
return nSum;
} // end Sum


// custom calculation script
// place field names as need into array
var aNames = new Array("Number.0", "Number.1", "Number.2",
"Number.3", "Number.4", "Number.5", "Number.6", "Number.7",
"Number.8","Number.9")
// do not change following code
event.value = Sum(aNames);





George Kaiser


Posted: 06 Apr 2011 02:33 PM
Left Button SpacerView user's profile profileRight Button Spacer
 
 
   
Go to previous topicPrev TopicGo to next topicNext Topic

go




Top | News | Developer | Find PDF Tools | Sponsorship | Tips | Home



Debenu's Planet PDF - a comprehensive site exclusively focused on Adobe Acrobat/PDF users and uses. Debenu's Planet PDF - Resources for Adobe Acrobat and PDF users

Please post PDF-related questions to our Planet PDF Forum forums.planetpdf.com. To send comments about this site please visit our contact page.
Planet PDF, Planet PDF Forum, PDF SDK - Debenu Quick PDF Library and Debenu are all copyright
© 2011 Debenu Pty Ltd.. All Rights Reserved. Privacy policy.