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

· 6년 전 · 3828 · 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년 전 조회 6,012
6년 전 조회 8,110
6년 전 조회 3,629
6년 전 조회 3,439
6년 전 조회 3,892
6년 전 조회 4,483
6년 전 조회 8,977
6년 전 조회 4,084
6년 전 조회 3,656
6년 전 조회 7,373
6년 전 조회 3,803
6년 전 조회 4,300
6년 전 조회 3,867
6년 전 조회 7,289
6년 전 조회 3,829
6년 전 조회 6,151
6년 전 조회 4,122
6년 전 조회 9,147
6년 전 조회 4,964
6년 전 조회 4,846
6년 전 조회 3,777
6년 전 조회 3,667
6년 전 조회 4,258
6년 전 조회 6,181
6년 전 조회 5,551
6년 전 조회 4,337
6년 전 조회 4,774
6년 전 조회 3,893
6년 전 조회 3,794
6년 전 조회 6,906