Calculate totals in Web Form Builder?...

User 2076706 Photo


Registered User
72 posts

Thanks Eric,

Inserted it into my HTML file; doesn't seem to work.

Do I need COST1, COST2, COST3, COST4 & COST5 instead of just COST?

Or, did I not insert the jQ code correctly?
>don<
User 187934 Photo


Senior Advisor
20,239 posts

Looks like you changed the name of your GrandTotal input to TOTAL. Give this a try.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
var jQ = $.noConflict(true);
// version 2
function calctotal(){
var total = 0;
jQ("input[name^='COST']").each(function(){
var value = jQ(this).val();
if(value >0 && jQ.isNumeric(value)){
total+=parseFloat(jQ(this).val(),10);
}
});
jQ("input[name=TOTAL]").val(total.toFixed(2))
}
jQ().ready(function(){
jQ("input[name^='COST']").change(function(){
calctotal()
});
});
</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 2076706 Photo


Registered User
72 posts

Thanks Eric,

Sorry about changing var name.
I know better, just had a temporary outbreak of the stupids.
>don<
User 2076706 Photo


Registered User
72 posts

Mornin' Eric,

Now realize I should've asked for the five COST items values be input by jG script.

If it isn't too much trouble your help will be appreciated.

>don<
User 187934 Photo


Senior Advisor
20,239 posts

A few questions. Your using checkboxes. Is it possible that the user could check all 9 options?
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 2076706 Photo


Registered User
72 posts

Yes. But, highly unlikely.
>don<
User 187934 Photo


Senior Advisor
20,239 posts

Is each line meant to set the requirements of one user? If so then you would be better off using radio buttons. It makes a huge difference in the coding structure.
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 2076706 Photo


Registered User
72 posts

Had considered that to begin with and decided needed checkboxes.
Will look at it again.
>don<
User 2076706 Photo


Registered User
72 posts

Eric,

How can I have Radio Button Element that allows none to be selected?
>don<
User 2076706 Photo


Registered User
72 posts

Did that but, when open the form cannot have a group without one item being selected. Just like a typical radio button group.
>don<

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.