How to perform 2 successive refreshes on web

I have a form with a lot of calculations. Some of the calculations are dependent upon the results of prior calculated fields. In order to have all of the fields recalculate without a full refresh when one of over 30 affected fields is entered, I have written javascript functions to update the affected fields on a new (unsaved) document as the user enters information.

However, there are a few fields that are populated by a DbLookup, which clearly does require a refresh.

The problem is that when this refresh runs, it updates the appropriate back-up field, but it does not re-compute all of the other fields affected by the new value.

I have tried calling the refresh, then calling the javascript function to perform the updates, but the js function runs before the refresh has updated the key field. I have also tried to run two successive refreshes which would also update all calculations, but it only runs once. I have tried this with and without the “Refresh fields…” option set on the dialog list field.

I need to either perform two successive refreshes after the selection of a drop-down list is changed, or find a way to delay the running of the js function until after the refresh has updated the lookup value.

Please note, at the time the user is entering information, and the calculations are being updated by the JS function, the document has not been saved, and does not fulfill necessary field validations to permit a save.

If anyone has any suggestions, it would be greatly appreciated.