You are here: irt.org | FAQ | JavaScript | Number | Q960 [ previous next ]
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>