Hey Victor, thank you so much for responding to my query!
My original version of this form had a bunch of fields hidden with conditional logic if the value of the field named "Dynamically Generated Cost" was NOT greater than zero. I just updated the form to get rid of that because after thinking about it, that design choice made no sense. To answer your specific question, the form uses cascading lookup fields as follows:
1. The matching values are presented in the field named "Vendor(s) Used" based on which value(s) are chosen in the field named "Service(s) Required."
2. The matching values are then presented in the field named "Web Development Services Required" based on which value(s) are chosen in the field named "Vendor(s) Used."
3. The matching values are then presented in a comma-separated list in the field named "Dynamically Generated Cost" based on which value(s) are chosen in the field named "Web Development Services Required."
What I need is to add JavaScript that converts the comma-separate list of values into individual values then adds them up and writes that sum as a numeric value into the field named "Dynamically Generated Cost." I asked Formidable support about how to do this and they said their plugin is unable to do an automatic sum calculation, but it's totally doable with JavaScript.
I can't write JavaScript from scratch like this, but if I had a well-commented script I'm confident I could modify and customize it to work for my needs.
So what I need specific help with is getting the JavaScript itself AND how to implement/use it in Formidable.
I figured out how to use the JavaScript math operator Math.ceil to round up to the nearest dollar amount when adding the value of two fields together. I have no idea how to implement what I'm trying to do with this calculation, however.
Can you help me with this?
Where do the numbers come from in the Web Development Services Required field?
Great Question! That data is populated using a Lookup Field that is configured as follows:
Get Options From = DATA FORM: Vendors+Products
Selector Field = Product
Filter by Lookup Fields = Vendor(s) Used
I also have that field set up with Conditional Logic as follows:
Show this field if Service(s) Required equals WebDev
I can't guarantee this snippet will work because I can't test it on your site, but it should give you a starting point. <a href="https://gist.github.com/vfontjr/83210a57ccafed9f31bffc32aa1347e3" rel="nofollow">https://gist.github.com/vfontjr/83210a57ccafed9f31bffc32aa1347e3</a>
Copy the snippet to the Before Fields area on the form's Customize HTML page. Change the field_xxx to the HTML id of the field containing the comma separated string. Use our browser's inspection tool to get the ID.
Full disclosure: I've not looked at the form in detail. My comment is basis of the theory presented in the opening post.
Can you put the lookups in a repeater and then have the value determined per repeater and then use this:
Hey Victor,
If I gave you a temporary Administrator login to the site would you be willing to help me with this further? I copied and pasted the exact code and put it in the location you said and changed the ID to be the correct one but it's not working. I would really like to get this working. I'd even be willing to pay you a bit if you can get it fixed and the investment would not be cost-prohibitive.
Please advise; thanks!
No, I won't access anyone's site that's not currently a client. My business focus is enterprise software engineering. If you want to contract with me, please apply at https://formidable-masterminds.com/project-application/.
Please login or Register to submit your answer
Hi Matt, I may be over simplifying, so forgive me if you've thought of this already:
Would the functionality of Formidable's [frm-math ..] feature work for you? Maybe nested Views with combined with get-set to grab the desired values, use the values in formulas and calcs built with frm-math, and use results to dynamically build params that would populate form fields?
Michael,
Thank you for your comment! I don't know if that would work or not because I've never used that feature... I specifically described in very explicit detail what I was trying to do in a support request I submitted through Formidable's help desk and they said what I was trying to accomplish could not be done with their plugin. They said I'd have to use JavaScript to accomplish my objective.
If your approach would actually work I'm all for trying it since I can't write custom JavaScript to save my life! I'll run your suggestion past support and see what they have to say. I'm by NO means a Formidable newbie, but when it comes to really advanced custom stuff like I'm trying to build with my dynamic WebDev Estimate Generator I'm feeling out my depth and I don't really have budget to pay someone to help with it. 🙂