Click here to Skip to main content
15,889,879 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Team,

I have the Code as follows.

C#
$('#allocateToSelect').change(function () {
           debugger;
           $("#allocateToSelect option:selected").val();
           GetQCCount();
       });



I have the Value inserted on my DropDown.DropDown as follow:
XML
<td>
                        <select id="allocateToSelect" class="combo150">
                           </select>
                    </td>

My problem is when i select the value in the dropdown . .Change Function is getting call which is fine.
But if I select the same value at second time my function is not getting call ,Why is it so .
please Guide me.
Thanks
Harshal
Posted

1 solution

The reason is since you are selecting the same option the second item, change event does not gets fired. If you select another value and select the first one again, event gets fired. Change event gets fired when the selection of items in the select clause are changed.
 
Share this answer
 
Comments
R Harshal 7-Apr-14 6:22am    
Now what to do is there any way to solve this issue . As i am new in Jquery .I want the Count when i select the same value of DropDown at second time. please guide me.
Thanks
Harshal.
R Harshal 7-Apr-14 6:24am    
Using JQuery, I want to detect when a user selects a value, even if they don't change the already selected value.
Please guide me.
Naz_Firdouse 7-Apr-14 6:30am    
you can use onclick event for the options
<pre lang="HTML">
<select id="selectBox" >
<option value="1" onclick="changeFunc();" >Option #1</option>
<option value="2" onclick="changeFunc();" >Option #2</option>
<option value="1" onclick="changeFunc();" >Option #1</option>
<option value="2">Option #2</option>
<option value="1">Option #1</option>
<option value="2">Option #2</option>
</select>
</pre>

<pre lang="Javascript">
<script type="text/javascript">

function changeFunc() {
//debugger;
var selectBox = document.getElementById("selectBox");
var selectedValue = selectBox.options[selectBox.selectedIndex].value;
alert(selectedValue);
}

</script>
</pre>
R Harshal 7-Apr-14 7:29am    
As i dont want to show the Value in DropDown.I already have the value in DropDwn.I just want to select the value from Drop and get the Count,If i select the same value as twice ,thrice ...and so on ,It should get the Count.For that purpose i need your help.Now i am getting the count when i am selecting the value at one time from DropDown.
Thanks
Harshal
Naz_Firdouse 7-Apr-14 6:41am    
for Jquery ,
<pre lang="HTML">
<select id="selectBox">
<option class="test" value="1">Option #1</option>
<option class="test" value="2">Option #2</option>
<option class="test" value="1">Option #1</option>
<option class="test" value="2">Option #2</option>
<option class="test" value="1">Option #1</option>
<option class="test" value="2">Option #2</option>
</select>
</pre>
<pre lang="Javascript">
$('#selectBox').change(function () {

var val = $("#selectBox option:selected").val();
alert(val);
});
$('.test').click(function () {

var val = $("#selectBox option:selected").val();
alert("val is "+val);
});

</pre>

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