I have created a form that gives the user the option to select from 1 of 4 radio selection menus (appear on conditional basis), each having 2-5 choices which contain different prices. I have created a “total” field for the amount to be calculated; however, I cannot seem to figure out how to include the other radio field menus. I do not want to add the fields… I simply want the correct price to appear based on the selection of the user.
I have searched, and searched, and searched for a solution, but to no avail. I have also updated to v 1.6.3 rc.
http://thesurfinstitute.com/the-institute/surf-sessions/surf-session-purchase/
Please help!!




February 22, 2012 at 7:56 pm
There isn't a built in way of selecting one of 4 fields for the total. This one will require some custom JavaScript. If you'd like to total up those four radio fields in your total field using the built in calculations, we can easily modify the JavaScript it produces.
February 23, 2012 at 12:55 pm
As I said, I do not want to total those fields (I figured out how to do that)... Instead, I need to have the total of whatever choice is selected to appear in my "total" field (through custom created JavaScript). Unfortunately, I am really green to all this and have no idea how to create such JavaScript.
Here's roughly what I have as options... Hoping someone out there is willing to guide me on this!!
I
A = $130
B = $110
C = $100
D = $80
E = $220
II
A = $330
B = $300
C = $270
D = $210
III
A = $100
B = $140
C = $60
D = $100
IV
A = $80
B = $120
February 23, 2012 at 1:07 pm
I understand you don't want a total of all four of those fields. As stated above, this will require custom javascript. If you would like our help pointing you in the right direction, it would save us a lot of time if we could copy the javascript produced by that built in calculation, and make changes to it, then remove the default calculation.
February 23, 2012 at 2:34 pm
Not really sure what you are asking me to send. I have no calculations right now because it is not offered through your built-in method. All I do have is the amount field pointing to a "total" field in the payments setting. Here is the code copied from that field. If this is incorrect, could you be more specific as to what you are referring to?
Thanks a lot... Truly appreciate it!
February 23, 2012 at 2:45 pm
I'm asking you to create a calculation in that field, even though it's not exactly what you need. Then, give us a link to you form so we can see the javascript that calculation produces. Either that, or you can work on this on your own or with the help of a developer. You can take a look at the custom examples here:
http://formidablepro.com/knowledgebase/field-calculations/
February 23, 2012 at 8:00 pm
Ya, I checked out the field calculations page several times, but it's all still a bit too greek to me still. I don't even know where to find the script myself or where to input it when, and if, I do figure it out.
So, I created a calculation that adds all 4 sections (even though that's not what I want). I thought maybe I needed to use "[if ID][/if ID]" in order to only get what was selected, but that didn't work. I'm usually pretty good at teaching myself all this, but I'm stumped. :-/
http://thesurfinstitute.com/the-institute/surf-sessions/surf-session-purchase/
Thanks for the help!
February 24, 2012 at 10:14 am
If statements won't work in the calculations. I see you added the calculation to add up those four fields. The section in red is added. Now, copy and paste this javascript into the "after fields" box of your customizable HTML, and remove your calculation from the total field.
<script type="text/javascript"> jQuery(document).ready(function($){ $('input[name="item_meta[396]"],input[name="item_meta[397]"],input[name="item_meta[398]"],input[name="item_meta[399]"]').change(function(){ var vals=new Array(); vals['396']=$('input[name="item_meta[396]"]:checked').val(); if(typeof(vals['396'])=='undefined'){vals['396']=0;}else{ vals['396']=parseFloat(vals['396'].match(/\d*(\.\d*)?$/)); } if(isNaN(vals['396'])){vals['396']=0;} vals['397']=$('input[name="item_meta[397]"]:checked').val(); if(typeof(vals['397'])=='undefined'){vals['397']=0;}else{ vals['397']=parseFloat(vals['397'].match(/\d*(\.\d*)?$/)); } if(isNaN(vals['397'])){vals['397']=0;} vals['398']=$('input[name="item_meta[398]"]:checked').val(); if(typeof(vals['398'])=='undefined'){vals['398']=0;}else{ vals['398']=parseFloat(vals['398'].match(/\d*(\.\d*)?$/)); } if(isNaN(vals['398'])){vals['398']=0;} vals['399']=$('input[name="item_meta[399]"]:checked').val(); if(typeof(vals['399'])=='undefined'){vals['399']=0;}else{ vals['399']=parseFloat(vals['399'].match(/\d*(\.\d*)?$/)); } if(isNaN(vals['399'])){vals['399']=0;} var selected_val=$('input[name="item_meta[395]"]:checked').val(); if(selected_val == 'Single Sessions'){ vals['397'] = vals['398'] = vals['399'] = 0; }else if(selected_val == 'Bulk Buy'){ vals['396'] = vals['398'] = vals['399'] = 0; }else if(selected_val == 'Intermediate Coaching'){ vals['396'] = vals['397'] = vals['399'] = 0; }else if(selected_val == 'Kids Under 13'){ vals['396'] = vals['397'] = vals['398'] = 0; } var total=parseFloat(vals['396']+vals['397']+vals['398']+vals['399']);if(isNaN(total)){total=0;} $("#field_hv1h69").val(total).change(); }); }); </script>February 24, 2012 at 11:01 am
Sorry to be dense, but am I to copy only what is in red or the whole thing in to the after fields? I've actually tried both, but to no avail. :( And when I remove the calculation, should I uncheck the "Calculate the default value for this field" box, or simply remove the equation below? I've actually tried all sorts of combinations, but nothing happens...
It looks to me that the very last part of the script directs the adding of the fields (right?), so I would assume I would that removed...?
THANK YOU!!!
February 24, 2012 at 12:02 pm
Copy and paste the entire block of javascript above. Do not make any changes. Uncheck the box to calculate the total.
February 24, 2012 at 12:21 pm
Done. I'm afraid nothing appears nor is there an amount if I submit to Paypal.
February 24, 2012 at 12:34 pm
You're missing a line in the javascript:
jQuery(document).ready(function($){
February 24, 2012 at 12:45 pm
Got that in there (not sure how I missed it when selecting "all" to copy/paste)...
But still nothing. Meh.
February 24, 2012 at 1:32 pm
Your javascript didn't paste correctly. You might need to move it into your theme files or something. You are missing slashes.
match(/\d*(\.\d*)?$/)
You have:
.match(/d*(.d*)?$/)
February 27, 2012 at 2:36 pm
Strange. It copies correctly into the "After Fields." Is the script not editable from a file within the formidable plugin folder? Any idea exactly where I need to move this script to?
Thanks again...
February 27, 2012 at 2:49 pm
It doesn't matter where you put it as long as it's included on the page. But don't put in in one of the plugin files. Put it somewhere it won't get overwritten when you update.
February 27, 2012 at 3:47 pm
Figured out how to call the .js file...
It's calling a "0" now in the "Total" field, but not the proper price per selection...
February 27, 2012 at 4:02 pm
The other javascript is still showing up on your page. Please complete this on your own or with the help of a developer. We've already provided far more custom help than we usually do, but we've got to draw a line somewhere. Sorry.
February 27, 2012 at 4:18 pm
I do appreciate the help... I suppose you should note in your pricing plan that support is limited and conditional, as I may have drawn a line when making the purchase.
February 27, 2012 at 4:40 pm
We assume that users do not purchase expecting full support for all their customizations. If you purchased with this expectation, we apologize. You will not find any premium plugin with unlimited support for your desired customizations. That is simply unrealistic. We provide unlimited support for the features included in our plugin, but anything that requires custom code falls outside of that support.
February 28, 2012 at 3:27 pm
Right. Actually, I wasn't expecting full support, but also wasn't expecting to be strung along as if I was going to receive a solution, only to be left hanging, steps away from getting my desired result. Your abrupt change in attitude makes a novice like myself feel intimidated to ask ANY questions...
But I will proceed anyway... In another post. :)
February 28, 2012 at 3:29 pm
We have provided the exact code you need to use. All you need to do is insert it on your page.