Removing currency on products


a client of mine don't want currency price on products in small , large product view.

i easy removed in large vies following script:

 

<script type="text/javascript">

document.onclick=myfunction();

function myfunction()

{

var str=document.getelementbyid("price").innerhtml;

var n=str.replace("kr"," ");

document.getelementbyid("price").innerhtml=n;

}

</script>

 

i thought same small product view, works on first one.

this must because goes id? (getelementbyid).

 

so thought change id class , change getelementbyid ...byclass , work,

but doesn't seem there work entirely same way.

 

any hints or pointers appreciated!

you use javascript's "getelementsbyclassname" method it's not entirely supported in older browsers (especially ie6-8) if i'd use jquery take account , should work across browsers.  it's simple jquery since can target elements using css-like selectors. 

 

you have jquery referenced in page or page template although don't know sure since didn't leave url. 

 

you can't have multiple ids on 1 page if small product layout contains id price (<div id="price">) should change class because that's invalid html.  if have multiple items on page using same markup need use classes.

 

change id of "price" class of "price". remove currency denotation (in case looks "kr") can still use replace method using use jquery can target classes on page:

 

(function($){

 

 

  $(document).ready(function() {

      var price = $(".price");

      var currency = "kr";

      price.each(function() {

          $(this).html($(this).html().replace(currency, ""));   

      });

  });

 

 

})(jquery);

 

 

what jquery function saying is, "when document ready, find each element class of "price" , update it's html content element's html content currency being replaced empty string".

 

if jquery library referenced in head of page or page template can include above javascript in <script> element after ".price" markup in page or can add existing javascript file that's referenced in head or body of page template.  important thing script must included after jquery referenced in page or page template.



More discussions in How to - HTML / CSS / JavaScript


adobe

Comments

Popular posts from this blog

Thread: gpg: Conflicting Commands

Adobe Acrobat Pro , Terminal Server Use

when i try using AE CC 3d camera tracker after the first step it says "Analysis solve failed." help?