Calculations... again - Page 1 - Post...

User 2736027 Photo


Registered User
70 posts

I am trying to get 'calculations' to work. I have configured two sets of 3 radio buttons each. Each button has a label, followed by a hidden value, eg: 'Single:25.00' Couple:30.00, Family:35.00, etc.When the radio button is selected, I would like to see the total value of Radio set 1 and set 2 appear in a third 'Total' field.

I found a sample script on the Forum, written by 'Eric Rohloff'. The script almost works! But, here is the problem. When WFB generates the html code, when it gets to the line(s) for the radio buttons the code incorrectly inserts 'Single:25.00' as the value, and not just the 'hidden' value '25.00'. If I manually edit the generated html code to remove the 'Single:' label part, then the script works as expected, adding up the values of radio button set 1, and set 2. Strange, but I also would have thought that the script statement 'total+=parseInt($(this).val(),10);' would have found the embedded numeric value in the string, but apparently not. Calculations seem to be a fairly common and consistent request in the forum, and I'm somewhat disappointed that it tends to get ignored, except for mainly Eric's posts of "try this", or "that". I would like some assistance in solving my short term needs, but would also like to see an easier built-in function to do this. Thanks in advance.

WTB ver 2.4, build 5318
P.S. the sample script used was found at: http://www.coffeecup.com/forums/web-for … orm-input/
User 187934 Photo


Senior Advisor
20,271 posts
Online Now

Can you share a link to your form so we can see it in action?
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2736027 Photo


Registered User
70 posts

Eric,

Thanks for looking... here is a temporary location: http://gvgrc.coffeecup.com/forms/Member-total-1/


Norm
WTB ver 2.4, build 5318
User 187934 Photo


Senior Advisor
20,271 posts
Online Now

Try changing this part
var value = $(this).val(),10;

to this
var value = $(this).val();
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2736027 Photo


Registered User
70 posts

Try changing this part
var value = $(this).val(),10;

to this
var value = $(this).val();


Originally, that is the code I had. It was copied from one of your earlier examples. Thinking that the radix was missing, I added the ',10' hoping it would parse the string and find only the integer as a decimal value , but it made no difference, with or without the radix. Any other thoughts?

Thanks for looking over the form.

User 2736027 Photo


Registered User
70 posts

Eric,

Attached is the script I was using.

Norm
Attachments:
User 187934 Photo


Senior Advisor
20,271 posts
Online Now

You also need to need to change the value of your radios to numeric.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2736027 Photo


Registered User
70 posts

You also need to need to change the value of your radios to numeric.


That is the part I'm trying to wrap my head around. If I replace any of the radio "labels" with a number instead of text, then it does work. But, my understanding (or, interpretation) of the function, was that a person could display a text label on the form, with a 'hidden' numeric value associated with that label, as in 'text_label:numeric_value'. In my case, I have entered 'Single:25.00'.

The problem (to me), is that when the program generates the html code, it copies the label:value intact, instead of inserting only the value. If I manually edit the html, it also works fine, but it is a step I should not need to do (IMHO).
<code snip>
<label id="item17_0_label"><input name="membership" id="item17_0_radio" required type="radio" data-hint="" value="Single:25.00" /><span class="fb-fieldlabel"
</code snip>

What is the recommended way to display text as a label, with either a hidden or displayed numeric value. Perhaps I'm going about this all wrong.

Thanks...
User 187934 Photo


Senior Advisor
20,271 posts
Online Now

Are you going to be using it on S-drive or manually exporting?
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2736027 Photo


Registered User
70 posts

Are you going to be using it on S-drive or manually exporting?


For the short term it will run on S-drive, as it is a proof of concept to provide the club executives the value of on-line forms, and the immediate response they would provide from our members. So for a single form, the S-drive will work.

Should the concept prove to be the asset I'm hoping for, then I could eventually see this and other forms become installed on the club's own web site. For now, the form 'just has to work easily', otherwise It will never be implemented.

One further question regarding the radio button properties: Even though I have configured the radio buttons as 'Text:Value', I would have thought the script statement 'total+=parseInt($(this).val(),10);' would have found the embedded numeric value. I need a bit of clarification if this is the proper code to be using, as it seems that the' parseInt' function should handle what I need, but apparently doesn't.


Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.