Displaying calculated result?

By: Chris Andrews | Asked: 07/12/2024
ForumsCategory: General questionsDisplaying calculated result?
Chris Andrews asked 5 months ago

I have a repeater field with a hidden number/calculation field for counting the number of repeater fields entered. 

Below the repeater field, I want to display the results - like:

     "You have entered 4 profiles"

It doesn't seem like I can put the field number (example: [50]) into an html field to display the results. That just displays "[50]". 

How can I accomplish this? 

Thanks, 

Chris  

1 Answers
Best Answer
Victor Font answered 5 months ago
Chris, your question is about something commonly done. The test results suggest you went down the wrong path and should probably back up a step or two in the software engineering process to take an alternate approach. Suggesting an accurate alternate approach without a hands-on look, just isn't possible. But you may be able to solve this with jQuery and a hidden field.
Chris Andrews replied 5 months ago

I'm sorry, I don't quite follow you.

Are you saying including the [50] in the html field is commonly done and should work?

The page I am working on is http://gbp.academy/join-monthly

I see I can put [50] into a text field as the default value and it is parsed. But if I put it into an html field, it is not.

My examples are the line directly above and directly below the 'Subscription Billing' heading. My goal is to remove the line above and have the information presented in the html,

Chris

Victor Font replied 5 months ago

If you want to tackle the jQuery yourself, this is how I would approach the problem. This is only a suggestion. There are other ways of achieving your goal. I think this is the easiest way to solve your problem unless you have deep Formidable knowledge. This is kind of old school, but sometimes old school works the best.

1. Use a hidden field on the form to store the repeater row count.

2. Ensure the hidden value is accurate when the form is saved because it's the value displayed in the HTML when the form is opened for editing in a browser.

3. Because the hidden field is updated in real time, it drives the HTML content. You can have any HTML element on a screen and update it's display text in real time as the user interacts with the repeater.

All of this happens in the browser with jQuery and creating the right listeners. It is a reliable, repeatable process that works as long as you maintain the accuracy of the hidden field. I don't think you'll find examples for any of this jQuery by searching online for this exact need. Displaying live text on the screen is a common programming need and you will find examples on the web.

What makes this unique is the repeater. Repeaters can be tricky to work with when developing real time events in the browser. This is because you have to know Ajax and how to listen to the repeater's Ajax.complete() event to know when the DOM has been updated by the addition or removal of a repeater row. And that is the business requirement you ask asking about in technical terms.

You can do this same thing by reading Formidable's variables in real time as well. You do not need to use a hidden field. I am suggesting the hidden field approach because I think it offers other benefits if the row count needs to be used for communications or statistical analysis. But again, you can retrieve the data using other means. You do not need a hidden field. The hidden field makes things a little easier I think as a pseudo-single-source-of-truth data element.

As an FYI, I would not choose this approach, or even consider it, actually, in an enterprise application development environment. I would do a full integration with Formidable. You know what your business goals are, if you even think that whatever you are building has future commercial value and can earn you a recurring passive income, may I suggest you take a pause and consider skipping the hidden field approach and go for a Formidable integration. The investment may be worth it, but that's only something you can figure out. It's the only way, though, to prepare a commercial app. But if you don't know how to do everything that takes, it could be costly to have someone do it for you.

Good luck with your project! Let us know if you find a solution.

Victor Font replied 5 months ago

To clarify your follow-up question. No adding a shortcode to the HTML and expecting real time updates is not common. It's the wrong approach.

Chris Andrews replied 5 months ago

Thank you Victor,

I looked over your explanation and kept playing around trying to find easier options. I realized I could use a number field to display the count, and then I used the field label inline, made the field read only, and used css to remove the border around the number so it appears just like text - and that worked and was easier (for me at least).

Thanks for your ideas though, it helped me to understand that the html field would not work for what I was doing and motivated me to figure out an alternative using skills I already had 🙂

Chris

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
crossarrow-right