Custom JavaScript - Controlling User Defined Price & Total Fields

Hi all,

I am loading a custom JS file in a Custom HTML block that performs a Fetch API lookup to a remote server. Basically, the setup is this:

  1. Customer types in a 5-digit invoice number from our internal server.
  2. Fetch performs lookup, and returns balance due. JS sets the User Defined Price field to this value. I have this working. It currently lets users modify the text field to change the price. This is fine as they should have the option to pay a different amount.

What I don’t have working is this:

  • Can I somehow trigger the updating of the Total field. Currently, this only updates if someone edits the User Defined Price field and changed it to another value… Can I trigger some event that makes this update from my JS file?

  • Can I hide the User-Defined price field until the value is changed by the Fetch lookup? What is the DOM handling that Conditional Logic would normally trigger for visibility? Basically, I want to require users to enter an invoice number and do a lookup first before they can edit the value or continue.