<script>
function sum(obj) {
  var oColl = obj.form.elements;
  var total = 0;
  for (var i=0; i < oColl.length; i++) {
    if (oColl[i].name.substr(0,4)=="item" && oColl[i].checked)
      total += parseInt(oColl[i].price);
  }
  obj.form.total.value = total;
}
</script>

<form>
<input type=checkbox name=item1 price=100 onClick="sum(this)">100원짜리<br>
<input type=checkbox name=item2 price=120 onClick="sum(this)">120원짜리<br>
<input type=checkbox name=item3 price=150 onClick="sum(this)">150원짜리<br>
<input type=text name=total value=0 readonly>
</form>
2007/11/22 15:18 2007/11/22 15:18

Trackback Address :: https://youngsam.net/trackback/84