Calculations... again - Post ID 243245

User 187934 Photo


Senior Advisor
20,271 posts
Online Now

If your going to manual export change the value of the radio in the myformname.html.
Proof of concept.
http://ericrohloff.com/coffeecup/ccforu … norm-lang/
How parseInt works with various variables.
http://www.w3schools.com/jsref/jsref_parseint.asp
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

If your going to manual export change the value of the radio in the myformname.html.

Yes, I know. I mentioned in my first post that if I manually edited the html code, then I could 'get it to work'. It's these extra steps that I was trying to avoid, considering that for any further changes to the form using WFB program would also require these manual changes as well. Not terribly user-friendly since the program almost does the job.

I re-read the documentation on how parseInt works (above). What I believe is happening is: "If the first character cannot be converted to a number, parseInt() returns NaN". Since parseInt sees a string like "Single:25.00" it returns a NaN, since the first character is not a number, but text. It's unfortunate that it would not "find an occurrence" of a number anywhere within the string, but it doesn't. Are you aware of another function that does? I think that would solve the problem.

Alternatively, if the program (WFB) would ONLY code the value of the radio button, instead of inserting the complete text label AND value, I'd be well on my way. So, I guess I'm faced with doing it the hard way, which is unfortunate, because for my proof-of-concept I will be simply uploading my form to S-drive, which doesn't allow me to directly edit the html file.

Thanks for all your help!!

Norm
User 187934 Photo


Senior Advisor
20,271 posts
Online Now

I have another option.;)
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 187934 Photo


Senior Advisor
20,271 posts
Online Now

This?:)
http://ericrohloff.com/coffeecup/ccforu … ndex2.html
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

Darn close!! At least it is working!!

If possible, I'd like the label more like this:

Single: $25 etc, showing a space and dollar sign. I'll need to read up more on the substr function. Looks good!

Thanks

User 187934 Photo


Senior Advisor
20,271 posts
Online Now

Your changing the rules.:( Why didn't you post that in the first place?:mad::lol:
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 187934 Photo


Senior Advisor
20,271 posts
Online Now

http://ericrohloff.com/coffeecup/ccforu … ndex2.html
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script>function calcsum(){
var total = 0;
$("input[type='radio']:checked").each(function(){
var value = $(this).val().substr ($(this).val().indexOf ( '$' ) + 1 );
if(value >0){
total+=parseInt(value,10);
}
});
$("input[name=sum]").val(total)
}
$().ready(function(){
$("input[type=radio]").change(function(){
calcsum()
});
});</script>
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

Your changing the rules.:( Why didn't you post that in the first place?:mad::lol:


Sorry Eric, I didn't think I was... I was trying to follow your lead and thought your earlier example included the price as being visible and part of the text field, making the Payments type as "none". I had been using Payments type as "Price Input" with a hidden value of price. Either way works for me, which is why if the price was to be displayed, then it would need the dollar sign. Sorry again for the confusion.

Your script above works perfectly now in your form. I just need to copy over the script into my form tomorrow and do the same magic as you have. Thanks ever so much for your patience!! This is coming along nicely now.

Norm
User 187934 Photo


Senior Advisor
20,271 posts
Online Now

That's ok Norm, It wasn't a hard change but sometimes it is. I didn't use it on an S-Drive form but if you look at the source code you will see the input values match the label so it's working as you last posted.:)
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 again for the great help. Your script is working exactly as I need!

In the meantime, I've removed my temporary form link so that I don't receive accidental submissions. ;o)

Norm

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.