Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Simple edit to JavaScript not working

    Hello All,

    I'm trying to edit a simple JavaScript which hides a class if a product's value is 0. I have products with options where the default product price is zero so I setup the default price to be $1 and tried to edit the JavaScript accordingly but I can't get it to work. I would appreciate any help.

    This code works if my product's value is 0 but I wish to change the code so it works if the value is 1.

    Code:
    <script type="text/javascript">
    $(document).ready( function() {
    var prody = $('.Value').html().replace("$", "");
    var prodz = $(prody).html().replace(".", "");
    var prodx = parseInt(prodz, 10);
    if(prodx<.01)
    {
    $('div.ProductGridWrap').hide();
    }
    else {}
    });
    </script>

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,618
    Thanks
    0
    Thanked 645 Times in 635 Posts
    if(prodx<1.01)
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •