Quantcast
Channel: DHIS2 Community - Latest topics
Viewing all articles
Browse latest Browse all 2126

JavaScript Percentage Calculation Not Working in DHIS2 Customized Form

$
0
0

Context:

I am working on a customized data entry form in DHIS2 and need to perform auto-calculations for percentages based on user-entered data. Specifically, I need to dynamically calculate and update several percentages as users input values into the form.

Problem:

The JavaScript code designed to calculate and update these percentages is not functioning as expected in the DHIS2 environment. While the script works in a standalone HTML environment (e.g., a local browser), it does not work when integrated into the DHIS2 form.

Details:

  • The JavaScript is intended to calculate percentages for fields such as “Contacts Tested,” “Tested Positive,” and “Linked to ART” based on input fields for “Contacts Reached,” “Contacts Tested,” and “Tested Positive.”
  • The script ensures logical constraints, such as “Contacts Tested” being less than or equal to “Contacts Reached.”
  • Despite the script working in isolated HTML tests, it fails to execute correctly within the DHIS2 customized form.

Steps Taken:

  1. I have verified that the JavaScript code is correctly linked and should run in the browser.
  2. I have ensured the IDs used in the script match those in the DHIS2 form.
  3. I have tested the script in a local environment, where it works as expected.
  4. However, when placed in the DHIS2 form, the calculations do not update as intended.

Request:

I need assistance with:

  • Understanding why the JavaScript code fails to execute properly in the DHIS2 environment.
  • Identifying potential conflicts or issues specific to DHIS2 that might cause this behavior.
  • Suggestions for debugging or modifying the script to ensure it works within the DHIS2 form.

Any guidance or insights from the community would be greatly appreciated. Thank you

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 2126

Trending Articles