Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery: add up attribute values on click
    primarykey
    data
    text
    <p>I have eCommerce site. I have product page where you can pick up different variations and addons to main product. I would like to be able to dynamically display price when customer is clicking on options.</p> <p>Basic html looks like this:</p> <pre><code>&lt;div class="addons"&gt; &lt;input type="radio" name="products[39][addons][Handles]" title="Handles" value="579" alt="7.00" class="options"&gt; Bronze Left &lt;input type="radio" name="products[39][addons][Handles]" title="Handles" value="580" alt="8.00" class="options"&gt; Bronze Right &lt;input type="radio" name="products[39][addons][Handles]" title="Handles" value="581" alt="9.00" class="options"&gt; Chrome Left &lt;input type="radio" name="products[39][addons][Handles]" title="Handles" value="582" alt="10.00" class="options"&gt; Chrome Right &lt;input type="radio" name="products[39][addons][Glass]" title="Glass" value="589" alt="18.00" class="options"&gt; Brass Clarity &lt;input type="radio" name="products[39][addons][Glass]" title="Glass" value="590" alt="20.00" class="options"&gt; Zinc Abstract &lt;input type="radio" name="products[39][addons][Glass]" title="Glass" value="591" alt="21.00" class="options"&gt; Zinc Elegance &lt;input type="radio" name="products[39][addons][Glass]" title="Glass" value="592" alt="23.00" class="options"&gt; Zinc Prairie &lt;/div&gt; </code></pre> <p>Value attribute is used for add to cart functionality and I cannot change that, price is set as alt but can be anything obviously and title is set jQuery click target.</p> <p>I need help with jQuery. The problem I have is that I don't know how to get var price to add up to each other outside click function.</p> <pre><code>$("input[type='radio'][title='Handles']").click(function() { price = $(this).val(); } $("input[type='radio'][title='Glass']").click(function() { price = $(this).val(); } </code></pre>
    singulars
    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.
 

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