야매가 아닌 ,,,정식 라디오 선택값 합산 정보
야매가 아닌 ,,,정식 라디오 선택값 합산본문
질문도 드리고 그래도 안되어서
이거 삽질끝에 어렵게 찾은 거에요
부득이 스택오버플로 진출하여,,ㅋ
<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
추천
4
4
댓글 3개
감사합니다 스크랩해놓고 나중에 봐야겠네요. 잘 사용할께요
감사합니다
감사합니다.