Вы находитесь на странице: 1из 3

Cat286

Creating calculation based on result of dropdown box


May 30, 2012 2:48 AM Categories: Windows Hi there. I am hoping someone will be kind enough to help me with some Javascript as it seems I am too blonde and middle aged to figure it out by myself. I have a dropdown box 'Member'. The value for Yes is 0. The value for No is 10. Then I have three check boxes. 'Day1' value is 35. 'Day2' value is 25. 'Dinner' value is 65. If Yes is selected, I want the sum of the check boxes if they are checked. (eg, total if all checked = 125) If No is selected, I want the value of each check box increased by 10. (eg, total if all checked = 155) I am using Acrobat X. Thanks in advance.

466 Views 4 Replies Latest reply: Cat286, May 30, 2012 3:09 PM

Replies

1. GKaiseril,
May 30, 2012 8:24 AM in reply to Cat286 Report

Have you accounted for the situation where any one or more of the items are not selected? Unselected check boxes have a value of "Off" and drop boxes for a blank or space value is a space.

| Mark as:

2. Cat286,
May 30, 2012 1:51 PM in reply to GKaiseril Report

Hmmm??? I think the simple answer to that is no! The drop box is a required field and can only select Yes or No. I am not sure what to do about the check boxes being off - doesn't this mean they just won't add if they are not checked? I am a complete novice when it comes to Javascript. How I wish it was as straightforward as Excel!

| Mark as:

3. GKaiseril,
May 30, 2012 2:42 PM in reply to Cat286 Report

Because of the fact that you want to add a constant to a number of values if a given condition is meet then you will need to use a custom calculation script. // get the value of the fields var cMember = Number(this.getField("Member").value); var nDay1 = this.getField("Day1").value; var nDay2 = this.getField("Day2").value; var nDinner = this.getField("Dinner").value; // define a varaiable for the sum var sum = 0; // day 1 plus adjustement if (nDay1 != "Off") sum += Number(nDay1) + cMember; // day 2 plus adjustement if ( Day2 != "Off") sum += Number(nDay2) + cMember; // dinner plus adjustement if (nDinner != "Off") sum += Number(nDinner) + cMember; event.value = sum; Excel is only easy if you accept Microsoft's view of calculations.

4. Cat286,
May 30, 2012 3:09 PM in reply to GKaiseril Report

Thanks so much. I would never have got that to work without your help. May you be forever blessed with health, wealth and happiness.

| Mark as:

Adobe Community powered by Jive SBS 4.5.6.3 forum software

Jive Software