admin管理员组

文章数量:1316541

I'm about to design a webshop, build upon the Big Cartel webshop system. The nearest currency they use is Euro, but I want Danish Kroner (DKK), which is 7.5 of Euro.

How can I multiply the number within a div.price?

I've found "jQuery Calculate"-plugin, but I can't figure out how it works.

Plugin site: .plugin.htm

Thank you in advance...

I'm about to design a webshop, build upon the Big Cartel webshop system. The nearest currency they use is Euro, but I want Danish Kroner (DKK), which is 7.5 of Euro.

How can I multiply the number within a div.price?

I've found "jQuery Calculate"-plugin, but I can't figure out how it works.

Plugin site: http://www.pengoworks./workshop/jquery/calculation/calculation.plugin.htm

Thank you in advance...

Share Improve this question edited Mar 7, 2014 at 18:27 Nick Endle 9451 gold badge5 silver badges10 bronze badges asked Jan 17, 2011 at 17:03 curly_bracketscurly_brackets 5,59815 gold badges62 silver badges103 bronze badges 12
  • 14 (Insert mandatory reference to jQuery basic arithmetic plugin here :) – Pekka Commented Jan 17, 2011 at 17:09
  • 2 Could you explain why you can't just use a bination of jQuery to get the current value in div.price and then just use good old javascript to multiply it by 7.5, then using jQuery to update the div? – Mark Robinson Commented Jan 17, 2011 at 17:09
  • Do you actually need to convert between currencies? Is it simply a matter of changing the symbol from Euro to DKK? – El Ronnoco Commented Jan 17, 2011 at 17:10
  • 1 Hi guys. I'm new to Javascript and doesn't know very much about it. However I use jQuery alot, and always search for plugins or snippets by searching "jquery ..."... @Mark: How would the script look like then? Or where can I find something like this? @El Ronnoco: The Danish currency is 7,5 times greater than Euro. That mean, that if I just change the symbol, the products would be 7,5 times cheaper than they really are. The customers would love it I bet. But not my client.. ;-) – curly_brackets Commented Jan 17, 2011 at 17:16
  • 1 I presume that what he actually needs is to extract a 1000.5 float from a 1.000,50 string. Whatever, the linked plugin seems to have an excellent documentation so it may help if you told us what you got so far and where you're stuck. – Álvaro González Commented Jan 17, 2011 at 17:18
 |  Show 7 more ments

2 Answers 2

Reset to default 3
$('div.price').text(function(i,v) {
    return Math.round(parseInt(v * 100, 10) * 7.5) / 100;
});

Live demo: http://jsfiddle/tbL5r/

$("div.price").each(function(){
 $(this).text(parseFloat($(this).text()) * 7.5);
});

But you really shouldn't be doing that with javascript.

本文标签: javascriptjQuery Multiply a number with 75Stack Overflow