야매가 아닌 ,,,정식 라디오 선택값 합산

· 6년 전 · 3741 · 3

질문도 드리고 그래도 안되어서

이거 삽질끝에 어렵게 찾은 거에요

부득이 스택오버플로 진출하여,,ㅋ

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
0 <input type="radio" name="ur" value="0" id="ur1" class="radi"/> <br />
2 <input type="radio" name="ur" value="2" id="ur2" class="radi"/> <br />

0 <input type="radio" name="haem" value="0" id="haem1" class="radi"/><br />
1 <input type="radio" name="haem" value="1" id="haem2" class="radi"/> <br />

0 <input type="radio" name="haew" value="0" id="haew1" class="radi"/><br />
1 <input type="radio" name="haew" value="1" id="haew2" class="radi" /> <br />

0 <input type="radio" name="syb" value="0" id="syb1" class="radi"/><br />
1 <input type="radio" name="syb" value="1" id="syb2" class="radi"/> <br />

0 <input type="radio" name="orm" value="0" id="orm1" class="radi"/><br />
1 <input type="radio" name="orm" value="1" id="orm2" class="radi" /> <br />

Total: <input type="text" name="total" id="total"/>

 

$(".radi").click(function() {
  var total = 0;
  $(".radi:checked").each(function() { total += +this.value; });
  $("#total").val(total);
});

 

 

출처:https://stackoverflow.com/questions/37135103/adding-radio-button-values-together-dynamically

|

댓글 3개

감사합니다 스크랩해놓고 나중에 봐야겠네요. 잘 사용할께요
감사합니다.
댓글을 작성하시려면 로그인이 필요합니다.

그누보드5 팁자료실

+
제목 글쓴이 날짜 조회
6년 전 조회 5,917
6년 전 조회 8,001
6년 전 조회 3,531
6년 전 조회 3,354
6년 전 조회 3,808
6년 전 조회 4,386
6년 전 조회 8,881
6년 전 조회 4,010
6년 전 조회 3,563
6년 전 조회 7,245
6년 전 조회 3,702
6년 전 조회 4,209
6년 전 조회 3,774
6년 전 조회 7,161
6년 전 조회 3,742
6년 전 조회 6,056
6년 전 조회 4,030
6년 전 조회 9,049
6년 전 조회 4,875
6년 전 조회 4,755
6년 전 조회 3,686
6년 전 조회 3,587
6년 전 조회 4,169
6년 전 조회 6,047
6년 전 조회 5,465
6년 전 조회 4,240
6년 전 조회 4,678
6년 전 조회 3,805
6년 전 조회 3,712
6년 전 조회 6,800