Enable/Disable using javascript

3 posts, 0 answers
  1. Azli
    Azli avatar
    11 posts
    Member since:
    Dec 2007

    Posted 04 Dec 2007 Link to this post

    Hi there,

    I'm new in this teleriks things. I try to enable/disable my textbox and combobox but it doesn't work. Below are my codes, can anyone help me on this.

    <script language="javascript" type="text/javascript">
    function CheckBox_Click(){
        if(document.Form1.chkJrnlSeq.checked){
         document.Form1.txtFrSeqNo.disabled = false;
         document.Form1.txtToSeqNo.disabled = false;
        }else{
         document.Form1.txtFrSeqNo.disabled = true;
         document.Form1.txtToSeqNo.disabled = true;
         document.Form1.txtFrSeqNo.value = "";
         document.Form1.txtToSeqNo.value = "";
        }              
           if(document.Form1.chkProdType.checked){        
                       var combo = <%=cboProductType.ClientID%>;
                        var input = document.getElementById(combo.InputID);
                        input.disabled = false;    
           }else{
                        var combo = <%=cboProductType.ClientID%>;
                        var input = document.getElementById(combo.InputID);
                        input.disabled = true;
           }
       }       
        </script>
    .
    .
    .
    .
    .
    <tr>
          <td style="width: 15px">
              <asp:CheckBox ID="chkJrnlSeq" runat="server">
              </asp:CheckBox>
         </td>
         <td style="width: 150px">
            <asp:Label ID="lblJrnlSeq" runat="server">1298^
            <!--1298 - Journal Sequence-->
            </asp:Label>
         </td>
         <td style="width: 300px">
             <radI:RadTextBox ID="txtFrSeqNo" runat="server"
                MaxLength="4">
             </radI:RadTextBox>
          </td>
          <td style="width: 300px;">
             <radI:RadTextBox ID="txtToSeqNo" runat="server"
                MaxLength="4">
             </radI:RadTextBox>
           </td>
       </tr>
       <tr>
           <td style="width: 15px">
              <asp:CheckBox ID="chkProdType" runat="server">
              </asp:CheckBox>
           </td>
           <td style="width: 150px">
             <asp:Label ID="lblProdType" runat="server">1221^
             <!--1221 - Product Type-->
             </asp:Label>
          </td>
          <td style="width: 300px">
            <radC:RadComboBox ID="cboProductType" runat="server" 
              AllowCustomText="False" Skin="WindowsOlive"
              SkinsPath="~/RadControls/ComboBox/Skins"
              AutoPostBack="False">
            </radC:RadComboBox>
           </td>
        </tr>

    In Code Behind : 

    Private Sub Page_Load
    (ByVal sender As System.Object, ByVal e As System.EventArgs)
    Handles MyBase.Load

       If Not Page.IsPostBack Then
            WebFormTool.LoadLabelForWebControlCollection
            (Me.Controls, CType(MyBase.objUserSession.GetSession
            (GlobalVar.clsSessionVar.SessionItem.LANGUAGE), Language),
             ColLanguageHastTable)
             LoadComboData()'ignore this
             chkJrnlSeq.Attributes.Add("OnClick", "CheckBox_Click()")
             chkProdType.Attributes.Add("OnClick", "CheckBox_Click()")
       End If
       btnReset.Attributes.Add("onClick", "javascript:return resetValue();")
       btnOK.Attributes.Add("onClick", "javascript:return OK_Click()")
       End Sub

  2. Rosi
    Admin
    Rosi avatar
    2529 posts

    Posted 05 Dec 2007 Link to this post

    Hi Azli,

    I suggest you use input.disabled = "disabled" instead of input.disabled = true;. also you can try use Enable() and Disable() methods of RadComboBox.  More about them you can find here -http://www.telerik.com/help/aspnet/combobox/combo_client_model.html

    Regards,
    Rosi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Azli
    Azli avatar
    11 posts
    Member since:
    Dec 2007

    Posted 05 Dec 2007 Link to this post

    Thanks Rosi. I use Enable() and Disable() and it works great.

    Regards,
    Azli
Back to Top