title: Changing decimal prices Javascript
body: <p>Im making a sweetshop project for my apprenticeship and ive done some test runs and have got all my code working but then i get my brief and the prices are changed depending on the weight and have got decimal prices instead of whole E.G £0.0.1 i thought this wouldnt make a difference but im not sure whats stopping the plus and minus button from changing the decimal price.</p>
  <pre><code>&lt;?php
  foreach ($result as $key =&gt; $value) { ?&gt;
      &lt;div class=&quot;col-md-4 inner-container&quot;&gt;
          &lt;div class=&quot;card border&quot;&gt;
  
        &lt;div class=&quot;column-image&quot; style=&quot; background-image: url(&lt;?php echo ($value['image']); ?&gt;&quot; &gt;
     &lt;/div&gt;
              &lt;h2&gt;&lt;?= $value['sweet_name'] ;?&gt;&lt;/h2&gt;&lt;br/&gt;
  
              &lt;p&gt;Price: £&lt;?= $value['price'] ; ?&gt;&lt;/p&gt;
  
          &lt;p&gt;Weight: &lt;?= $value['weight'] ; ?&gt;g&lt;/p&gt;
  
  
      £&lt;span id=&quot;prices&quot;&gt;&lt;?php echo ( $value['price'] );  ?&gt;&lt;/span&gt;&lt;br/&gt;
  
      &lt;span id=&quot;weight&quot;&gt;&lt;?php echo ( $value['weight'] );  ?&gt;&lt;/span&gt; g&lt;br/&gt;
  
      &lt;button onclick=&quot;minus()&quot;&gt; - &lt;/button&gt;&lt;span id=&quot;quantity&quot;&gt; 1 &lt;/span&gt;&lt;button onclick=&quot;plus()&quot;&gt; + &lt;/button&gt;&lt;br/&gt;  
  
      &lt;!-- runs the function addcookie in javascript and passes paramater id  --&gt;
     &lt;a href=&quot;/basket.php&quot;&gt;&lt;button class=&quot;column-button&quot; onclick=&quot;addcookie(&lt;?php echo  $value['id']; ?&gt;)&quot;&gt;Add to basket&lt;/button&gt;&lt;/a&gt;
  
      &lt;/div&gt;
  &lt;?php } ?&gt;
  
  
  
  &lt;script&gt;
      // these varibles are to not get [object HTMLSpanElement] 
      var weight = &lt;?php echo ( $value['weight'] );  ?&gt;;
      var price = &lt;?php echo $value['price']; ?&gt;; 
  function addcookie(id){
  
      // element can be anything in HTML
      // innerHTML gets anything inside the html tags E.G quantity = 1
  
  var quantity = document.getElementById('quantity').innerHTML; 
  
  
  
  var id = &lt;?php echo $value['id']; ?&gt;;
  
  // creates the cookie with a key and a value and also creates a path to be stored 
  // this means i can access it on any page E.G basket.php
  
      document.cookie = &quot;zzz_&quot;+id+&quot;_id=&quot;+id+&quot;; ;path=/&quot;;
      document.cookie = &quot;zzz_&quot;+id+&quot;_quantity=&quot;+quantity+&quot;; ;path=/&quot;;
      document.cookie = &quot;zzz_&quot;+id+&quot;_weight=&quot;+weight+&quot;; ;path=/&quot;;
  }
  function plus(){
  
      // parseint changes strings into intergers 
  
      document.getElementById('quantity').innerHTML = parseInt( document.getElementById('quantity').innerHTML) +1;
  
      document.getElementById('prices').innerHTML = parseInt( document.getElementById('prices').innerHTML) +price;
  
  
      document.getElementById('weight').innerHTML = parseInt( document.getElementById('weight').innerHTML) +weight;
  
  }
  function minus(){
  
      if (document.getElementById('quantity').innerHTML &gt; 1){
      document.getElementById('quantity').innerHTML = parseInt( document.getElementById('quantity').innerHTML) -1;
  
  
      document.getElementById('prices').innerHTML = parseInt( document.getElementById('prices').innerHTML) -price;
  
      
  
      document.getElementById('weight').innerHTML = parseInt( document.getElementById('weight').innerHTML) -weight;
  
  }
  }
  
  &lt;/script&gt;
  
  </code></pre>
  <p>i'm just wondering what i'm doing wrong? i've tried changing my parseInt to a ParseDouble but there was no change at all.</p>