2012-03-15 4 views
1

안녕 전문가를 선택하지 않았지만의 RadioButton 값이 있습니다가이 코드를 참조하십시오

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> 
    <ContentTemplate> 
     <table border="1" cellpadding="8" cellspacing="0" width="700px" style="background-color: Aqua"> 
      <tr> 
       <td style="direction: rtl"> 
        &nbsp; 
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
       </td> 
       <td style="direction: ltr"> 
        F1     </td> 
      </tr> 
      <tr> 
       <td style="direction: rtl"> 
        <asp:DropDownList ID="Drp_1" runat="server" ClientIDMode="Static"> 
         <asp:ListItem Value="1">Head of household</asp:ListItem> 
         <asp:ListItem Value="2">Spouse</asp:ListItem> 
         <asp:ListItem Value="3">Child</asp:ListItem> 
        </asp:DropDownList> 
       </td> 
       <td> 
        F2 
       </td> 
      </tr> 
      <tr> 
       <td style="direction: rtl"> 
        <asp:RadioButtonList ID="Rad_7" runat="server" ClientIDMode="Static"> 
         <asp:ListItem Text="1" Value="1"></asp:ListItem> 
         <asp:ListItem Text="2" Value="2"></asp:ListItem> 
         <asp:ListItem Text="3" Value="3"></asp:ListItem> 
         <asp:ListItem Text="4" Value="4"></asp:ListItem> 
        </asp:RadioButtonList> 
       </td> 
       <td> 
        F3 
       </td> 
      </tr> 
      <tr> 
       <td> 
       </td> 
       <td> 
        <asp:Button ID="btn" runat="server" Height="44px" Text="Submit" ClientIDMode="Static" 
         Width="207px" /> 
       </td> 
      </tr> 
     </table> 
    </ContentTemplate> 
</asp:UpdatePanel> 
<asp:UpdateProgress ID="UpdateProgress1" runat="server"> 
    <ProgressTemplate> 
     <h1 style="color: Green"> 
      Progress ... 
     </h1> 
    </ProgressTemplate> 
</asp:UpdateProgress> 

을하고 나는이 jQuery 코드를 사용 : 나는 지정된 스크립트에 브레이크 포인트를 사용할 때

<script type="text/javascript"> 

    function pageLoad() { 
     $(document).ready(function() { 
      $("#Drp_1").on("change", function() { 
       if ($(this).val() != null && $(this).val() == 2) { //<<<<< This Line 
        if ($('#Rad_7 input').val() != null && $('#Rad_7 input').val() > 1 && $('#Rad_7 input').val() != 2) { 
         alert('Wrong option'); 
        } 
       } 
      }).change(); 
     }); 
    } 
</script> 

문제입니다 줄 및 바로 창을 사용할 때이 코드 $('#Rad_7 input').val()1Rad_7에서 옵션을 선택하지 않았습니다. 내 실수는 어디 갔지? 이 확인 여부를 경우

감사

답변

2

$('#Rad_7 input').val()은 첫 번째 라디오 버튼의 value 상관없이 얻을 것이다. 첫번째 라디오 버튼의 값이 1이기 때문에 당신은 똑같이 보입니다.

라디오 버튼의 값을 확인하려면이 값을 사용하십시오. 그룹의 라디오 버튼 중 어느 것도 다음 확인되지 않는 경우

$('#Rad_7 input:checked').val(); 

undefined을 줄 것이다.

+0

내가 선택한 값을 어떻게 얻을 수 있습니까? – Arian

+0

수정 된 답변 확인. – ShankarSangoli

관련 문제