|
Q960 How can I create a form with monetary values that when selected from a drop down box the correct values are added together to give a final figure?
irt.org | Knowledge Base | JavaScript | Number | Q960 [ previous next ]
Q960 How can I create a form with monetary values that when selected from a drop down box the correct values are added together to give a final figure?
Try:
<script language="JavaScript"><!--
function update(form) {
var total = 0;
for (var i=0;i<form.money.length;i++) {
if (form.money.options[i].selected) {
total += form.money.options[i].value - 0;
}
}
form.total.value = '$' + cent(total);
}
//--></script>
<form>
<select name="money" multiple size="3">
<option value="9.99">Book
<option value="29.99">Album
<option value="199.99">Bookcase
<option value="888.88">Computer
</select>
<p>Total: <input type="text" name="total"size="8">
<p><input type="button" onClick="update(this.form)" value="Click Me">
</form>
|
Feedback on 'Q960 How can I create a form with monetary values that when selected from a drop down box the correct values are added together to give a final figure?'
|
|
Copyright © 1996-2008 irt.org, All Rights Reserved.