JSFiddle - React, Tailwind, and code Playground
HTML
<form name="config" id="config">
<div class="row-fluid">
<h3>Memory</h3>
<input type="radio" name="section1" value="4gb" onclick="changePrice(1,0)" checked="checked" />4gb
<br/>
<input type="radio" name="section1" value="8gb" onclick="changePrice(1,100)" />8gb (+$100)
<br/>
<input type="radio" name="section1" value="16gb" onclick="changePrice(1,200)" />16gb (+$200)
</div>
<div class="row-fluid">
<h3>Primary Hard Drive</h3>
<input type="radio" name="section2" value="dell" onclick="changePrice(2,0)" checked="checked" />Dell
<br/>
<input type="radio" name="section2" value="asus" onclick="changePrice(2,100)" />Asus(+$100)
</div>
</form>
<div id="price"></div>
JavaScript
var displayPrice = document.getElementById("price");
var baseNum = 200;
displayPrice.innerHTML = baseNum;
var sections = {};
function changePrice(section, val) {
// add or update the section value
sections[section] = val;
// start with the base price
var sum = baseNum;
// loop over all the sections and add them to the base price
for (var key in sections) {
sum = sections[key] + sum;
}
displayPrice.innerHTML = sum;
}