Show a total $ Amount - Page 2

User 74729 Photo


Registered User
14 posts

Yes I wanted to. If there is a function to get the either the left or right digits, I could format the content differently and then use a function that would be something like: nbr=Left(fieldcontents,3).

But if it's complicated I'll just redo that part of the form and have the user enter a value into a number field and hope it's correct. Unfortunately I need to get this done by Wed.

thanks.
User 187934 Photo


Senior Advisor
20,190 posts
Online Now

Your values for the options makes this a little more difficult. There will need to be some if statements to declare a variable based on the selection.
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 74729 Photo


Registered User
14 posts

I'm using number boxes now for each value and have pasted in the script and changed my total field name, and am about to export.

However, not sure what option to select under content. the default is Hyperlink - I removed the hyperlink code that got pasted in so I just have the script code. <script>....</script>

I had some pop up that said the script should work in preview mode, which it doesn't, so I'll finish up and go through the upload process. Just wondering If I should change "Hyperlink" to one of the other values listed, such as Override Styles, etc.?
User 74729 Photo


Registered User
14 posts

I have it working now using Eric's script and number fields.

However, I see that it works fine if the user types the numbers in. But if they use the updown arrows to change the field that is not reflected in the total. I assume that has something to do with the keyup function, which probably detects key presses.

Well, that is good enough - I'll adjust to go with that. Thank you very much for that script.
User 187934 Photo


Senior Advisor
20,190 posts
Online Now

Cool.: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 2032081 Photo


Registered User
5 posts

I would like to be able to have two number fields added together then multiplied by 5.

How would I adjust the code for that?

John
User 187934 Photo


Senior Advisor
20,190 posts
Online Now

This should help you out.
http://ericrohloff.com/coffeecup/ccforu … dmultiply/
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 2147646 Photo


Registered User
233 posts

Hi Eric, thank you very much for sharing this script :) I am trying to modify it so that it uses name attribute instead of the id and also subtract a number instead of multiply. This is what I have but it is not working
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script><script type="text/javascript">$(document).ready(function(){
$('[name=total_1').attr('readonly', true);

$('input').keyup(function(){
var valone = $('[name=cost_a]').val();
var valtwo = $('[name=cost_b]').val();
var valthree = $('[name=cost_c]').val();
var valfour = $('[name=cost_d]').val();
var valfive = $('[name=cost_e]').val();
var valsix = $('[name=deposit]').val();
var total = (parseInt(valone) + parseInt( valtwo) + parseInt( valthree) + parseInt( valfour) + parseInt( valfive)) - valsix;
if(total>0){
$('[name=total_1]').val(total.toFixed(2));
}
});
});</script>

Can you point me in the right direction?
Thanks :)

User 187934 Photo


Senior Advisor
20,190 posts
Online Now

Give this a try.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script><script type="text/javascript">$(document).ready(function(){
$('input[name=total_1').attr('readonly', true);

$('input').keyup(function(){
var valone = $('input[name=cost_a]').val();
var valtwo = $('input[name=cost_b]').val();
var valthree = $('input[name=cost_c]').val();
var valfour = $('input[name=cost_d]').val();
var valfive = $('input[name=cost_e]').val();
var valsix = $('input[name=deposit]').val();
var total = (parseInt(valone) + parseInt( valtwo) + parseInt( valthree) + parseInt( valfour) + parseInt( valfive)) - valsix;
if(total>0){
$('input[name=total_1]').val(total.toFixed(2));
}
});
});</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 2147646 Photo


Registered User
233 posts

Hi Eric, I found the reason why it was not working... it was because I was using conditionals to show the inputs, and as the function is waiting for all inputs to be filled before it would run. So what I done was add a value of 0 to the inputs. It was then possible to use conditionals :)
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script><script type="text/javascript">$(document).ready(function(){
$('[name=total_1]').attr('readonly', true);
$('[name=cost_a], [name=cost_b], [name=cost_c], [name=cost_d], [name=cost_e]').val("0");

$('input').keyup(function(){
var valone = $('[name=cost_a]').val();
var valtwo = $('[name=cost_b]').val();
var valthree = $('[name=cost_c]').val();
var valfour = $('[name=cost_d]').val();
var valfive = $('[name=cost_e]').val();
var valsix = $('[name=deposit]').val();
var total = (parseInt(valone) + parseInt( valtwo) + parseInt( valthree) + parseInt( valfour) + parseInt( valfive)) - valsix;
if(total>=0){
$('[name=total_1]').val(total.toFixed(2));
}
});
});</script>

Its a great time saver to use the name rather than id as everything can be done within WFB without sifting through the source code to see what FB used for the id's :)

Thanks again!


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.