How to Display Default Values in HTML Field from Same Form?

By: Mark Hansen | Asked: 11/01/2023
ForumsCategory: General questionsHow to Display Default Values in HTML Field from Same Form?
Mark HansenMark Hansen asked 1 year ago
Thanks in advance for any guidance. I have a form that allows users to calculate specific things based on the values of roughly 10 form fields. Before the form is ever submitted, I have a summary section that makes use of calculations based on their input, and displays the approximate price range for their selected options. 

I'd like to summarize their choices in this summary section with an html field that explains their selections and a few other hidden variables I have built in. 

For example, if a user selects: 
  • Blue from the widgets color
  • 20 from the widgets quantity
  • Shipping is to California from state dropdown
My output in an html field would be along the lines of: The estimated cost above includes your selection of 20 Blue widgets, shipped to the state of California. To place your order, click the reserve button below to begin your purchase. I am able to use default values in text fields, paragraph fields set to read only etc, but is there any way to drop them into an html field which just looks much cleaner? Thanks again,
Mark
1 Answers
Mark HansenMark Hansen answered 1 year ago

Resolved. In case anyone has interest in how I resolved this, I was able to do so myself with a "Paragraph" field set to read only with "auto-grow" in the advanced options and a default value of the text I wanted it to read out. Then I applied css styling to the specific form field ID in order to have it look like a simple text paragraph. Replace the x in the brackets with your form field numbers. Default value: The estimated cost above includes your selection of [x] [x] widgets, shipped to the state of [x].....  Replace "field_yjxms" with your own form field ID. #field_yjxms {font-weight:bold!important;color:#282828!important;padding:0!important;border:none!important;box-shadow:none!important;resize:none!important} Good luck.  

Jane OnoratiJane Onorati replied 12 months ago

Hey thanks Mark for sharing! I am replacing ids with keys everywhere in my existing forms and views, but one challenge was how to make this work with my HTML fields that show values from another field in the same form. I learned that you can't use keys in HTML fields, and the only solution seemed to be to use Paragraph fields instead, but I wasn't sure how to style them.

Your settings on the field and css did the trick! The only thing is I can't put text in them that I want to have breaks in. However one advantage is that paragraph fields can be on the same page as the field with the value you want to display. Can't do that with HTML fields. -Jane

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