Caculation field - Post ID 228164

User 2657606 Photo


Registered User
11 posts

Yes, but it's showing 0.05 in the fee field instead of fee amount. In your example it should show .1
User 187934 Photo


Senior Advisor
20,265 posts

Ok. I just didn't understand. Start the elevator music.: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,265 posts

Ok done with the job that pays the bills.:lol:
First floor home electronics and calculators.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
function calculate(){
var valsel = $('[name="select7"] option:selected').val();

if(valsel != "Non U.S."){
var valone = 1.04;
var feeper = .04;
}
else {var valone = 1.05;
var feeper = .05;
}
var valtwo = $('#item2_number_1').val();

if(valtwo!=""){

var fee = valtwo * feeper;
var value = parseFloat(fee).toFixed(2);
$('#item3_number_1').val(value);
var fee = valtwo * valone;
var total = parseFloat(fee).toFixed(2);
$('#item5_number_1').val(total);

}
}
</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 2657606 Photo


Registered User
11 posts

Eric Rohloff wrote:
Ok done with the job that pays the bills.:lol:
First floor home electronics and calculators.

LOL. That works perfect. Thank you much.

My next big hurdle will be loading a form when the user chooses from a drop down box. Right now I have 6 different forms that I will need to load from a drop down box. Hope this is possible. :/

Thanks again!
User 187934 Photo


Senior Advisor
20,265 posts

Tap on the screen if you need some tips.
I would first try using a Jquery on change event to show and hide each form.:cool:
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 38401 Photo


Senior Advisor
10,951 posts

Why not use the conditionals and create one form to handle them all? :)
User 2657606 Photo


Registered User
11 posts

Jo Ann wrote:
Why not use the conditionals and create one form to handle them all? :)


I thought about that, but wasn't sure if it would be real slow to load 6 forms on one page. The application form is pretty long. Is it possible to group a section of fields to load together with conditionals?

Eric, I will look into the Jquery on change and see if I can figure it out.

Thanks, Kevin
User 2770302 Photo


Guest
1 post

Hi,

I am trying to add up 10 fields on my form and have the total displayed but i am having difficulties. Could you take a look and let me know how to start. I need to know how to properly reference the field names. I have attached a link to the form

The amount fields are named Amount1 to Amount 10 and the Total Refund is just labelled total.
http://ymcaofniagara.coffeecup.com/CampCancellationForm/

Any help that you can provide would be greatly appreciated
User 187934 Photo


Senior Advisor
20,265 posts

Selects are targeted
$('select[name="mydropdown"]').val()

inputs are targeted
$('input[name="total"]').val()

Then what I like to do is assign a class with JQuery to the totals and have a function sum those.
Example:
$('input[name="quantity"]').on('keyup', function() {
var amount = $(this).val() * 10;
if(amount > 0){

$('input[name="total"]').val(amount);
$('input[name="total"]').addClass( "sum" );
calc_total();
}
});

Here's the calc_total function that gets called.
function calc_total() {
var sum_total = 0;
$('.sum').each(function(){
sum_total += parseFloat(this.value);
$('input[name="grand_total"]').val(sum_total);
});
}

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

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.