Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You wanna count every time u clicked on a radtio button it counts the value on the previous click(when first time clicked the value is zero). I would create an hidden field to put the totale amount in. </p> <p>In your example u used 'this' if ur writing in jQuery you cant use it that way(in my opinion). If your writing a function like: </p> <pre><code>function foo(value) { this.value = value; }; var foobar = new foo('test'); alert(foobar.value); </code></pre> <p>Then u should use the way u did.</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { $("input[name=rmr]").click(function() { //Get totale amount var total = parseInt($("input[name=mem-totale]").val()); //Get checked value var amount = parseInt($(this).val()); //Change it in your way switch (amount) { case "1": amount = 3; break; case "2": amount = 5.5; break; case "4": amount = 10; break; }; var totale_amount = total + amount; //Put totale in the mem-totale $("input[name=mem-totale]").val(totale_amount); //Put tottale in your label $("div.total-text").text("£" + (totale_amount)); }); }); &lt;/script&gt; &lt;input id="radio-1" type="radio" name="rmr" value="1"&gt; &lt;label for="radio-1"&gt;£3&lt;/label&gt; &lt;input id="radio-2" type="radio" name="rmr" value="2"&gt; &lt;label for="radio-2"&gt;£5.5&lt;/label&gt; &lt;input id="radio-3" type="radio" name="rmr" value="4"&gt; &lt;label for="radio-3"&gt;£10&lt;/label&gt; &lt;div class="total-text" style="font-size:36px"&gt;£10&lt;/div&gt; &lt;input type="hidden" name="mem-totale" value="0" /&gt; </code></pre> <p>Goodluck with it</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload