i've tried to count the value of selected option of the following multiple combo box.
<form method="post" name="transaksi" action="proc.php">
<select name="bulan_catering[]" id="id_cur_month_catering" size="12" multiple="multiple" onchange="update_catering()">
<option value="jul-20132014-3500">[2013-2014] July</option>
<option value="aug-20132014-3700">[2013-2014] August </option>
<option value="sep-20132014-4100">[2013-2014] September </option>
<option value="oct-20132014-4200">[2013-2014] October </option>
<option value="nov-20132014-4800">[2013-2014] November </option>
<option value="dec-20132014-5100">[2013-2014] December </option>
</select>
Total payment: <input type="text" name="catering">
And i use this simple javascript to get the value.
<script type="text/javascript" language="javascript">
function update_catering() {
var num_month_catering = document.getElementBy("id_cur_month_catering").value;
var cur_payment_catering = num_month_catering.substring(13);
document.transaksi.catering.value = cur_payment_catering;
}
</script>
What i need to do is, for example if user selects july, august and september, it should count 3500+3700+4100. and the result for total payment should 11300. But it doesn't work as i want. It is only showing value of the last selected option. in this case it shows 4100 (last value). Can some one help me to do the right way in javascript as i explained above, please.
Thank You.