Click here to Skip to main content
15,912,457 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HEllo Team,
I have a input as follows:
HTML
<pre lang="xml">&lt;td&gt;
                        &lt;select id=&quot;allocateToSelect&quot; class=&quot;combo150&quot;&gt;
                             &lt;/select&gt;
                    &lt;/td&gt;
I am inserting the DropDown option value as follows:
<pre>function GetDisplayQCID() {
            debugger;
            $.ajax({
                url: 'QCAllocation.aspx/GetDisplayQCID',
                type: 'POST',
                contentType: 'application/json; charset=utf-8',
                dataType: "json",
                success: function (result) {
                    debugger;
                    if (result.d != '') {
                        if (result.d != '' &amp;&amp; result.d != null) {
                            DisplayQCIDList = JSON.parse(result.d);
                            var drawRow = function (qcIDs) {
                                /*var dropdownQC = document.getElementById('qcSelect');*/ //for append to another DropDown.
                                var dropdownQC = document.getElementById('allocateToSelect');

                                /*var dropdownAllocateToQC = document.getElementById('allocateToSelect');
                                dropdownAllocateToQC.innerHTML = dropdownAllocateToQC.innerHTML + dropdownQC.innerHTML;*/

                                var opt = document.createElement('option');
                                opt.innerHTML = '';
                                dropdownQC.appendChild(opt);

                                for (var i = 0; i &lt; qcIDs.length; i++) {
                                    opt = document.createElement('option');
                                    opt.value = qcIDs[i].Id; // it will give the ID through which we can find the value which present in DropDown.
                                    opt.innerHTML = qcIDs[i].NetworkId;
                                    dropdownQC.appendChild(opt);
                                }
                            }

                            drawRow(DisplayQCIDList);
                            /*$('#qcSelect option').clone().appendTo('#allocateToSelect');*/ //for append to another DropDown.
                            manageOverlay(false);
                        }
                    }

                },
                error: function (error) {
                    manageOverlay(false);
                    alert(error.responseText);
                },
                async: false
            })
        };


I have the Function in Jquery as follows:
Java
&amp;lt;pre lang=&amp;quot;cs&amp;quot;&amp;gt;$(&amp;amp;#39;#allocateToSelect&amp;amp;#39;).change(function () {
    debugger;
    $(&amp;amp;quot;#allocateToSelect option:selected&amp;amp;quot;).val();
    GetQCCount();
});&amp;lt;/pre&amp;gt;&lt;/pre&gt;</pre>


I am facing problem on selecting the Same value in dropdown .At first time it get call on change function but on second time when i select the same value it cannot get call.Please guide me .How to get it solve please tell me.

Thanks
Harshal
Posted
Updated 9-Apr-14 2:30am
v2
Comments
Murugesan22 9-Apr-14 8:49am    
You sholud select other value after select previous value

Dropdownlist change event means change the value then only it will work
Please correct your code. It is not readable. Post it again with proper pre tags.
Ajith K Gatty 9-Apr-14 9:31am    
Hi Harshal,

Your code is correct. If you fire an event based on selection changed then it will only fire when the dropdown value changes.Select a value and event fires. click again on the same and event doesnt fire.because value has not changed. If you want every time to fire an event when you click then fire the event based on click.
[no name] 9-Apr-14 9:43am    
Hi Ajith,
But how .will you tell me please
Thanks
Harshal
Ajith K Gatty 9-Apr-14 9:53am    
if you are implementing on selection changed,If the event is firing when you click for the first time and doesn't fire when you click on it for the second time your coding is correct. If you select different value than the previous,then event is not firing then only it is wrong. According to your explanation code is correct i feel.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900