「shoppingCart」の選択をフォームの入力「formdesc」としてどのようにキャプチャしますか?
サンプル:<ol id="shoppingCart" name="formdesc"></ol>
動作しません。
HTML:
...
<select id="apparelType">
<option selected="selected" value="na">Select</option>
<option value="0">T-Shirt</option>
<option value="1">Shorts</option>
<option value="2">Hat</option>
<option value="3">Bag</option>
</select>
<label for="numb">Total: <span>$</span></label>
<input id="numb" type="number" name="formbal" value="0.00" />
<input id="pretaxTotal" type="hidden" value="0.00" />
<ol id="shoppingCart"></ol>
</form>
JS:
<script type="text/javascript">
$('#apparelType').change(function(){
var apparelType = $('#apparelType');
var fmapVal = apparelType.val();
if (fmapVal == 'na') {
alert('Please select an apparel type.');
} else {
var appVal = [ 15, 20, 25, 30 ];
var description = apparelType.find('option:selected').text();
var cost = appVal[fmapVal];
var pretaxTotal = parseInt($('#pretaxTotal').val());
var subtotal = pretaxTotal + cost;
var updatedTotal = ( subtotal * 1.06 ).toFixed(2);
$('#pretaxTotal').val(subtotal);
$('#numb').val(updatedTotal);
$('#shoppingCart').append('<li>' + description + '</li>');
}
});
</script>