Change Label based on Item

2 posts, 1 answers
  1. Karl Ranville
    Karl Ranville avatar
    28 posts
    Member since:
    Mar 2013

    Posted 05 Apr 2013 Link to this post

    Hi,

    My shopping cart check out page contains a RadCombobox with few items and there is a RadTextBox with a label given declaratively. For one particular item selected from the RadCombobox, I want to change the textbox label to another Text. How can I do this in JavaScript?

    Karl
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 Apr 2013 Link to this post

    Hi Karl,

    Please have a look at the following sample code which works fine at my end.

    ASPX:
    <telerik:RadComboBox ID="RadComboBox1" runat="server" Label="Select Your Card Type "
        OnClientSelectedIndexChanged="OnClientSelectedIndexChanged">
        <Items>
            <telerik:RadComboBoxItem runat="server" Text="" />
            <telerik:RadComboBoxItem runat="server" Text="Master Card" />
            <telerik:RadComboBoxItem runat="server" Text="Visa Card" />
            <telerik:RadComboBoxItem runat="server" Text="American Express" />
            <telerik:RadComboBoxItem runat="server" Text="Other Card" />
        </Items>
    </telerik:RadComboBox>
    <br />
    <br />
    <telerik:RadTextBox ID="RadTextBox1" runat="server" Label="Enter CVV : ">
    </telerik:RadTextBox>

    JavaScript:
    <script type="text/javascript">
        function OnClientSelectedIndexChanged(sender, args) {
            var RadTextBox1 = $find('<%=RadTextBox1.ClientID %>');
            if (args.get_item()._text == "Other Card") {
                $get(RadTextBox1._wrapperElementID).getElementsByTagName("label")[0].innerHTML = "Your Custom Label : ";
            }
            else {
                $get(RadTextBox1._wrapperElementID).getElementsByTagName("label")[0].innerHTML = "Enter CVV : ";
            }
        }
    </script>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top