Announcement

Collapse
No announcement yet.

Savings as percentage

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Savings as percentage

    I'm trying to setup up my homepage specials to display percentage off instead fo dollar amount? I was hoping with this tag it would work but it's still grabbing a dollar amount.

    <!--START: savings_percentage-->
    <div id="discount"><span id="discount-amt">[savings_percentage]%<br/>OFF</span></div>
    <!--END: savings_percentage-->

    has anyone gotten something like this to work yet?

  • #2
    Not sure if you figured this out, but you have to do the math in your code.

    Add some javascript where you want it to display:

    Code:
    <script>
    var MSRP = "[price2]"; 
    var Save = "[savings]"; 
    var Perc = 0;
    MSRP = MSRP.replace(/\$/g,''); 
    Save = Save.replace(/\$/g,''); 
    Perc = Save/MSRP * 100; 
    document.write("(" + Math.round(Perc) + "%)");
    </script>
    For convenience, you could build a function and simple send the info to it like:

    function Percentage ([price2], [savings])
    Last edited by molder101; 08-19-2011, 12:20 PM.

    Comment


    • #3
      I had wondered about that, I thought there might have been an option I just missed rather than doing the math like that.

      Thanks for the piece of code saves me a few minutes of writing at least

      Comment

      Working...
      X