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

Get-Set Value of Combobox in javascript.

2 Answers 95 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Kishor Dalwadi
Top achievements
Rank 2
Kishor Dalwadi asked on 30 Jul 2010, 10:20 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 30 Jul 2010, 10:35 AM
Hello Kishor Dalwadi,


Attach the OnClientSelectedIndexChanged event to RadComboBox than attaching onchange.

CS:
        cmbSite.OnClientSelectedIndexChanged = "SiteChange";



-Shinu.
0
Kishor Dalwadi
Top achievements
Rank 2
answered on 30 Jul 2010, 11:01 AM
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
Tags
ComboBox
Asked by
Kishor Dalwadi
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 1
Kishor Dalwadi
Top achievements
Rank 2
Share this question
or