2014-06-17 3 views
3

전체클릭하면 나타나는 라디오 버튼의 값을 얻으려고

나는 이것을 설정했다. 이제 수정이 필요합니다.

  1. 페이지가 처음로드 될 때 라디오 버튼 중 하나가 미리 선택됩니다. 모두 충족 또는 모두 충족 또는 모두 누락. 지금은 모든 Met 버튼이 선택되었습니다.
  2. 모든 라디오 버튼이 비활성화되어 있습니다. 확인란을 선택한 다음 행 ID를 선택하면 텍스트 영역에 해당 행의 라디오 버튼 값만 채워집니다 (부분적으로 작동).
  3. 확인란을 선택하지 않으면 값이 채워집니다. (작동하지 않음)
  4. 사용자가 다른 라디오 버튼을 선택한 경우 (확인란 선택 후) 값을 업데이트해야합니다 (작동)
  5. 또한 누락 라디오 버튼을 선택하면 텍스트 필드가 표시되고 입력 된 값을 업데이트해야합니다. (Throws Undefined)

나는 꽤 많은 일을했지만, 모든 것이 작동하지 않습니다.

전문가가 다시 도움을받을 수 있습니까? 이와

$("input:radio").hover(function() { 
$(this).prev('.r-title').show(); 
}, function() { 
if (!$(this).is(':checked')) { 
    $(this).siblings('.r-title, .m-notes').hide(); 
} 
}); 

//Radio Buttons 

$("input:radio").click(function() { 
$(this).parent().parent().find('.r-title, .m-notes').hide(); 
var totalRd = $('table').find('input:radio:checked').length; 
var clicked = []; 
$("#totalRd .rd-count").html(totalRd); //Counts the radio buttons clicked 
$(this).siblings('.r-title, .m-notes').show(); 
$('table').find("input[type=radio]:checked").each(function() { 
var selectedId = $(this).parent().parent().attr('id'); 
var newVal = ($(this).next('.m-notes:visible').length) ? this.value + "~" +    $(this).next('.m-notes:visible').val() : this.value; 
clicked.push(selectedId + "~" + newVal); 
}); //checked 
$("#inputhere").val(clicked.join('|')); 
}); 

//Input Field for Missing Radio Button 

$('.m-notes').keyup(function() { 
var $self = $(this); 
var clicked = []; 
$('table').find("input[type=radio]:checked").each(function() { 
    var selectedId = $(this).parent().parent().attr('id'); 
    var newVal = this.value + "~" + $(this).next('.m-notes').val(); 
    clicked.push(selectedId + "~" + newVal); 
}); //checked 
$("#inputhere").val(clicked.join('|')); 
}); 

//CheckBox 
var clicked=[]; 
$("input:checkbox").change(function(){ 
$(this).parent().parent().find("input[type=radio]").prop('disabled',!this.checked); 
}); 

답변

4

Fiddle Here 당신은 체크/선택 해제 체크 박스를 선택한 라디오의 가치를 얻을 :

$("input:checkbox").change(function(){ 
    $(this).parent().parent().find("input[type=radio]").prop('disabled',!this.checked); 

    $("#inputhere").val(""); 
    $(".chkBx").each(function(){ 
     if($(this).prop("checked")){ 
      var txtVal = $(this).parents("div").eq(1).find("input[type='radio']:checked").val(); 
      var idRowVal = $(this).parents("div").eq(1).attr("id"); 
      var textboxPrevValue = $("#inputhere").val(); 
      var textAndIdVal = textboxPrevValue + txtVal + " " + idRowVal + " "; 
      $("#inputhere").val(textAndIdVal); 
     } 
    }); 

}); 

fiddle

+0

추가되었지만 작동하지 않습니다. – 19eggs

+0

체크 박스 변경 기능에 추가했습니다. 저장 버튼 클릭을 원하십니까? –

+0

내가 이해할 수 있을지 모르겠다. 그러나 체크 박스를 클릭했을 때 선택된 라디오 버튼의 행 ID와 값만 텍스트 영역에 채워 져야한다. 이 확인란을 선택하지 않으면 텍스트 영역에 없어야합니다. 희망이 도움이됩니다. – 19eggs

1

당신은 당신의 상태

을이를 추가해야
$(this).parents("div").eq(1).find("input[type='radio']").val();//add this 
+0

불쾌감은 없지만 나는 오래 전에 당신과 같은 대답을 올렸습니다. –

+0

안녕하세요! Sagar, Alek는 잠시 전에이 글을 올렸습니다. 업데이트 된 바이올린을 보시기 바랍니다. – 19eggs

관련 문제