get_selecteditem() wrong value

3 posts, 0 answers
  1. Trevor
    Trevor avatar
    22 posts
    Member since:
    Jul 2010

    Posted 24 Aug 2010 Link to this post

    Hi,

    This is probably a simple fix but, I have java script that is called by the onselectedchanged() event for a combobox. I want to get the value of the new selected item. However, the value I get is the old value that was selected. Here is my code.

    <tr id="trForwardEmail" runat="server">
                <td>
                    Forward Email To:
                </td>
                <td width="10">
                </td>
                <td>
                    <telerik:RadComboBox ID="cmboForwardEmail" runat="server" width="200" OnClientSelectedIndexChanging="ShowCheckbox"/>
                </td>
            </tr>
    function ShowCheckbox(sender, eventArgs)
     {
         
        var checkbox = document.getElementById("<%= trSaveEmail.ClientID %>");
        var cmboBox = $find("<%= cmboForwardEmail.ClientID %>");
        alert(cmboBox.get_text());
       if(cmboBox.get_selectedItem().get_text() != "No Forwarder")
       {
            checkbox.style.visibility = "hidden"; 
       }
       else
       {
            checkbox.style.visibility = "visible";
       }
    }

    Any help?

    Thanks,
    Trevor
  2. Cori
    Cori avatar
    562 posts
    Member since:
    Jul 2010

    Posted 24 Aug 2010 Link to this post

    Hey Trevor,

    Change the line cmboBox.get_selectedItem().get_text() with eventArgs.get_item().get_text() and see if that helps.
  3. Trevor
    Trevor avatar
    22 posts
    Member since:
    Jul 2010

    Posted 24 Aug 2010 Link to this post

    Perfect Thanks!
Back to Top