I created a simple site that asks the user the type of shirt they want, and what color. Each selection has a value. I want the total cost of the users selection to be displayed. So far implementing the Javascript has been giving me trouble.
Here is my html code as well as my attempted Javascript
function calculatePrice() {
//get data
var blank = document.getElementById("blank");
var long = document.getElementById("long");
var sweater = document.getElementById("sweater");
var graphic = document.getElementById("graphic");
var colorSelect = document.getElementById("colorSelect");
var color = colorSelect.options[colorSelect.SelectedInex].value;
//convert to integers
blank = parseInt(shirt);
long = parseInt(shirt);
sweater = parseInt(shirt);
graphic = parseInt(shirt);
color = parseInt(color);
//calculate
var total = shirt + color;
//display total
document.getElementById("displayTotal").value = total;
}
<div class="form">
<form id="clothingForm">
<fieldset>
<legend>Select items to order.</legend>
<div class="shirt">
<label class="shirtLabel">Shirts</label>
<p><br/>
<input type="radio" name="selectedShirt" id="blank" value="B2" onclick="calculatePrice()" />
<label class="sLabel" for="blank">Blank Tee - $2</label>
<p><br/>
<input type="radio" name="selectedShirt" id="long" value="5" onclick="calculatePrice()" />
<label class="sLabel" for="long">Longsleeve - $5</label>
<p><br/>
<input type="radio" name="selectedShirt" id="sweater" value="7" onclick="calculatePrice()" />
<label class="sLabel" for="sweater">Sweater - $7</label>
<p><br/>
<input type="radio" name="selectedShirt" id="graphic" value="12" onclick="calculatePrice()" />
<label class="sLabel" for="graphic">Graphic Tee - $12</label>
</div>
<div class="color">
<label class="colorLabel" for="color">Color</label>
<select id="colorSelect" name="color" onchange="calculatePrice()">
<option value="0" id="color">Select Color</option>
<option value="1" id="color">White + ($1)</option>
<option value="1" id="color">Black + ($1)</option>
<option value="2" id="color">Blue + ($2)</option>
<option value="2" id="color">Yellow + ($2)</option>
<option value="2" id="color">Red + ($2)</option>
<option value="2" id="color">Pink + ($2)</option>
<option value="4" id="color">Tie Dye + ($4)</option>
</select>
</div>
<button type="button" onclick="calculatePrice()">Your Total</button>
<input type="text" id="displayTotal" size=8>
</fieldset>
</form>
</div>