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


    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?

  2. Answer
    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.

    <telerik:RadComboBox ID="RadComboBox1" runat="server" Label="Select Your Card Type "
            <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" />
    <br />
    <br />
    <telerik:RadTextBox ID="RadTextBox1" runat="server" Label="Enter CVV : ">

    <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 : ";

Back to Top