[jQuery] Re: How do I add/subtract currency with jquery?
You might find "Masked Input" plugin useful: http://digitalbush.com/projects/masked-input-plugin/ Also on creating your custom jQuery plugins: http://jquery-howto.blogspot.com/search/label/plugin On Sat, Feb 7, 2009 at 2:10 AM, webopolis wrote: > > I've done this with straight Javascript for years, I just thought with > all the other cool things that have been done with jquery, there would > be a plugin for this as well. Thanks for the help. > > Kevin > > On Feb 6, 3:52 pm, sem101 wrote: >> You don't need jQuery for math, it's simple JavaScript. But -- you can >> use jQuery to get elements of your forms >> >> var qty = parseInt($('input#qty').val()) || 0; >> var product1 = parseFloat($('input#product1').val()) || 0; >> var discount = parseFloat($('input#discount').val()) || 0; >> var grandtotal = (qty * product1) - discount; >> >> $("div#total").html('$' + grandtotal.toFixed(2) + ''); >> >> This would roughly create variables to hold your form input values, >> then show the grandtotal in a div called #total. You can grasp the >> concept.The things to look up are Floating Point, Integers and >> Decimals, etc. >> >> http://www.w3schools.com/js/default.asp >> >> On Feb 6, 3:13 pm, webopolis wrote: >> >> >> >> > How do I add/subtract currency with jquery?- Hide quoted text - >> >> - Show quoted text -
[jQuery] Re: How do I add/subtract currency with jquery?
If you're JS savvy, often times it's better to write your own jQuery functions than rely on an over-bloated plugin. However, you might find some of the plugin tutorials interesting on this page... http://docs.jquery.com/Tutorials Good luck! On Feb 6, 4:10 pm, webopolis wrote: > I've done this with straight Javascript for years, I just thought with > all the other cool things that have been done with jquery, there would > be a plugin for this as well. Thanks for the help. > > Kevin > > On Feb 6, 3:52 pm, sem101 wrote: > > > You don't need jQuery for math, it's simple JavaScript. But -- you can > > use jQuery to get elements of your forms > > > var qty = parseInt($('input#qty').val()) || 0; > > var product1 = parseFloat($('input#product1').val()) || 0; > > var discount = parseFloat($('input#discount').val()) || 0; > > var grandtotal = (qty * product1) - discount; > > > $("div#total").html('$' + grandtotal.toFixed(2) + ''); > > > This would roughly create variables to hold your form input values, > > then show the grandtotal in a div called #total. You can grasp the > > concept.The things to look up are Floating Point, Integers and > > Decimals, etc. > > >http://www.w3schools.com/js/default.asp > > > On Feb 6, 3:13 pm, webopolis wrote: > > > > How do I add/subtract currency with jquery?- Hide quoted text - > > > - Show quoted text -
[jQuery] Re: How do I add/subtract currency with jquery?
I've done this with straight Javascript for years, I just thought with all the other cool things that have been done with jquery, there would be a plugin for this as well. Thanks for the help. Kevin On Feb 6, 3:52 pm, sem101 wrote: > You don't need jQuery for math, it's simple JavaScript. But -- you can > use jQuery to get elements of your forms > > var qty = parseInt($('input#qty').val()) || 0; > var product1 = parseFloat($('input#product1').val()) || 0; > var discount = parseFloat($('input#discount').val()) || 0; > var grandtotal = (qty * product1) - discount; > > $("div#total").html('$' + grandtotal.toFixed(2) + ''); > > This would roughly create variables to hold your form input values, > then show the grandtotal in a div called #total. You can grasp the > concept.The things to look up are Floating Point, Integers and > Decimals, etc. > > http://www.w3schools.com/js/default.asp > > On Feb 6, 3:13 pm, webopolis wrote: > > > > > How do I add/subtract currency with jquery?- Hide quoted text - > > - Show quoted text -
[jQuery] Re: How do I add/subtract currency with jquery?
You don't need jQuery for math, it's simple JavaScript. But -- you can use jQuery to get elements of your forms var qty = parseInt($('input#qty').val()) || 0; var product1 = parseFloat($('input#product1').val()) || 0; var discount = parseFloat($('input#discount').val()) || 0; var grandtotal = (qty * product1) - discount; $("div#total").html('$' + grandtotal.toFixed(2) + ''); This would roughly create variables to hold your form input values, then show the grandtotal in a div called #total. You can grasp the concept.The things to look up are Floating Point, Integers and Decimals, etc. http://www.w3schools.com/js/default.asp On Feb 6, 3:13 pm, webopolis wrote: > How do I add/subtract currency with jquery?