[제나플러스] 체크한 것만 합계를 표시하는 스크립트 > 팁앤테크

본문 바로가기

사이트 내 전체검색

뒤로가기 팁앤테크

[제나플러스] 체크한 것만 합계를 표시하는 스크립트

본문

<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>


추천0

댓글목록 0

등록된 댓글이 없습니다.

전체 825건 5 페이지
게시물 검색
Copyright (c) 株式会社YHPLUS. All rights reserved.

사이트 정보

株式会社YHPLUS / 대표 : ZERO
〒171-0014 東京都豊島区池袋2-41-5 アーバン154 8F
050-5539-7787
오픈카카오톡 (YHPLUS) :
https://open.kakao.com/o/slfDj15d

PC 버전으로 보기