How to get a value from an external javascript file to be read and updated in form calculations

By: Tamsin Carter | Asked: 03/10/2023
ForumsCategory: Code HelpHow to get a value from an external javascript file to be read and updated in form calculations
Tamsin CarterTamsin Carter asked 1 year ago

Hello I have some custom code which works out a value based on a file upload to my formidable form. Once the value is calculated it is passed back to the form using the field ID. The value currently shows in the form but if I try to use that value in a calculation by using the field ID then the value does not show/update until I have moved back and forth in the pages of my form. More details:

  1. The external code includes this javascript code: priceField = "361"
    This is where the value of priceField is passed to field 361 in the formidable form.
  2. Field 361 shows the value correctly
  3. In another field I have a calculation involving [361] but there the value of 361 is not called in. Even if the field is simply set to show [361], it doesn't show.
  4. If I move to the next page in my form and then back (moving back seems to be the important action) then the value of 361 is called correctly into the calculation.
  5. When I asked Formidable for help they have demonstrated that they can add javascript to the form to set a value of a field and this works correctly. Therefore it must be something to do with the way the value is called or updated from the external code and so they cannot help me further.

Solutions: Ideally I would like the value called in from the external code to behave as any other value and be updated and usable in calculations. It would be ok if moving forward a page in the form caused the value to be updated and usable in calculations as I can have the field 361 on one page and the calculations on the next (however this does not work currently as it seems to be moving back one page which makes it update). Further help with javascript: The external code I have performs a word count on uploaded documents and then works out a price based on some other options and a pricing structure. This code has been written in javascript and php and edited a few times. It is difficult for me to make changes and some aspects of it seem messy (even though it does work). I would be interested in finding a programmer to look at it and help me to simplify it and understand how to make changes to it. Looking forward to any responses. Thank you  Tamsin    

1 Answers
Rob LeVineRob LeVine answered 1 year ago
I suggest reaching out to someone on the list here
Victor Font replied 1 year ago

I agree with Rob. You need a developer to look at the code you're using. priceField = "361" isn't meaningful when inquiring about accessing a field. There would never be an input id of 361 in the rendered HTML.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community