This is a migrated thread and some comments may be shown as answers.

get_selecteditem() wrong value

2 Answers 86 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Trevor
Top achievements
Rank 1
Trevor asked on 24 Aug 2010, 05:01 PM
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 Answers, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 24 Aug 2010, 06:18 PM
Hey Trevor,

Change the line cmboBox.get_selectedItem().get_text() with eventArgs.get_item().get_text() and see if that helps.
0
Trevor
Top achievements
Rank 1
answered on 24 Aug 2010, 06:42 PM
Perfect Thanks!
Tags
ComboBox
Asked by
Trevor
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
Trevor
Top achievements
Rank 1
Share this question
or