Expand my Community achievements bar.

Drop Down Menu Dependent Calculation

Avatar

Level 2

I've seen many examples of drop down menus leading to a calculation with raw data built in. Used mainly for invoices, where a series of products have set prices. While my calculation is dependent on the selection in the drop down menu it is also dependent on the entry of another field.

To be more clear:

The user enters an amout in both the receipt and the disbursement field, then the user chooses one of three options in a drop down menu (collection, closing, interest bearing). Finally there is a hidden field which populates  the amount entered from either the receipt field or the disbursement field, dependent on whether collection or closing were selected, populates the receipt amount entered. If the Interest Bearing amount is selected the field would populate the disbursement amount *(-1).

Would really appreciate some help! Thank you in advance.

Anna

10 Replies

Avatar

Former Community Member

Anna,

Take a look at the attached. I posted it yesterday to another forum question. See http://forums.adobe.com/thread/684341?tstart=0 for reference.

Steve

Avatar

Level 2

Hi Steve, Thanks for the message. I'm actually in need of a different function.

I'll try to be more clear....

users are inputting accounting data

receipts1      disbursements1     dropdown1 (includes: Collection, Closing, Interest Bearing)

the user enters a number in the receipt field, then the disbursement field and then selects on of the three options in the dropdown.

If the user selects collection or closing, the invisible field populates the number that the user entered into the receipts1

if the user selects Interest Bearing, the invisible files populates the number in the disbursements1 field and then multiples it by (-1)

Is this something you could help me with?

Thanks,

Anna

Avatar

Former Community Member

Is this what you are after? See attached.

Steve

Avatar

Level 2

That's exactly what I need! Thanks! How can I get the code behind it? I need the calc for my form, to fold into a greater sum.

Thanks so much!

Avatar

Former Community Member

Go to the toolbar and click Windows > Script Editor.

Here is the code behind the drop-down exit event:

// form1.page1.dd::exit - (JavaScript, client)


if (this.rawValue == "Interest Bearing") {

  if (form1.page1.disbursements.isNull) {

    form1.page1.other.rawValue = null;

  }

  else {

    form1.page1.other.rawValue = form1.page1.disbursements.rawValue * -1;

  }

}

else {

  if (form1.page1.receipts.isNull) {

    form1.page1.receipts.rawValue = null;

  }

  else {

    form1.page1.other.rawValue = form1.page1.receipts.rawValue;

  }

}

Here is the code behind receipts exit event:

// form1.page1.receipts::exit - (JavaScript, client)


if (!(form1.page1.dd.isNull)) {

  form1.page1.dd.execEvent("exit");

}

Here is the code behind disbursements exit event:

// form1.page1.disbursements::exit - (JavaScript, client)


if (!(form1.page1.dd.isNull)) {

  form1.page1.dd.execEvent("exit");

}

Steve

Avatar

Level 2

Ok I've dropped it in and I'm not getting any errors but it isn't working for me. Could I send you the

form to identify the issue?


Thanks again.

Avatar

Former Community Member

Sure. Send the form to stwalker.adobe@gmail.com.

Avatar

Former Community Member

Anna,

The problem is due to the way you had defined the drop-down. You had selected 'Specify Item Values'. By doing so the rawValue of the drop-down becomes the value rather than the text. By default, each item in the drop-down is assigned a value starting from 0. Un-check 'Specify Item Values'.

Untitled.png

Additionally, I encourage renaming pages and sub-forms. Rather than have a sub-form called  #subform[0], give it a name. It can be less verbose and far less confusing when you come back to this form 6 months or a year from now.

Steve

Avatar

Level 2

Hi Steve,

Thanks for the recommendations. I unchecked the 'specify item' box and still no luck.

Unfortunately, the calculation isn't populating. I currently have it marked as visible in order to build out the larger calculation. Then I intend to hide it. Is there anything else that you could see that would get this working again?

Thanks

Anna

Avatar

Former Community Member

I will send you my working version of your form via email. I re-named the sub-form to page1 and changed all the scripts. That must be the problem.

Steve