Get-Set Value of Combobox in javascript.

3 posts, 1 answers
  1. Kishor Dalwadi
    Kishor Dalwadi avatar
    40 posts
    Member since:
    Nov 2009

    Posted 30 Jul 2010 Link to this post

    Hi sir,

    I am get and set combobox value in javascript.

    But this javascript woking in firefox perfectly. bu not in internet exploere 8.

    This javascript function is not calling in Internet Explorer.

    my code is below:
    -----aspx:
    <script language="Javascript" type="text/javascript">
        function SiteChange() {
            var combo = $find("<%= cmbSite.ClientID %>");
            var selectedItem = combo.get_selectedItem();
            var selectedValue = selectedItem.get_value();
            var preval = document.getElementById("<%= hdnValue.ClientID %>");
            if (preval.value != selectedValue) {
                var ans = confirm('Are you sure change the site?')
                if (!ans) {
                    preval.value = selectedValue;
                    var item = combo.findItemByValue(selectedValue);
                    if (item)
                        item.select();
                }
            }
        }
    </script>
    <asp:HiddenField ID="hdnValue" runat="server" Value="0" />
    <telerik:RadComboBox ID="cmbSite" runat="server">
    </telerik:RadComboBox>

    ----C# :
     cmbSite.Attributes.Add("onchange", "SiteChange();");

    So please give me proper solution.

    Thanks.

    Kishor Dalwadi
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 30 Jul 2010 Link to this post

    Hello Kishor Dalwadi,


    Attach the OnClientSelectedIndexChanged event to RadComboBox than attaching onchange.

    CS:
            cmbSite.OnClientSelectedIndexChanged = "SiteChange";



    -Shinu.
  3. Kishor Dalwadi
    Kishor Dalwadi avatar
    40 posts
    Member since:
    Nov 2009

    Posted 30 Jul 2010 Link to this post

    Hello Shinu

    Thanks for reply.

    I do this javascript is calling in ie8.

    But item not select.

    please give me the solution for that.

    Kishor Dalwadi
Back to Top