Click here to Skip to main content
15,897,226 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have used dropdownchecklist to show dropdown with check boxes in it .
now iam unable to use onkeydown event plz do help me....
thanks in advance
Posted
Comments
[no name] 4-Jan-13 6:38am    
Check the following link for reference. "http://msdn.microsoft.com/en-us/library/system.windows.forms.control.onkeydown.aspx"
Member 9664530 4-Jan-13 6:52am    
<script type="text/javascript">
$(document).ready({
$(".s1").dropdownchecklist();
});
</script>

<select multiple='multiple' onchange='SelectedChange(this);' önkeydown='HandleKey(this,event);' id='select1' class='s1'>
<option>option1</option>
<option>option2</option>
<option>option3</option>
<option>option4</option>
<option>option5</option>
<option>option6</option>
</select>

here iam getting the dropdown with checkboxex but the method onkeydown is not fired .....

1 solution

The Plugin you used in this example supports parameters like onComplete, onItemClick. hence refer to their documentation for more examples,

As a suggestion you can find "onItemClick" option as an alternative for onkeydown

Example Code Snippet:
C#
$(".s1").dropdownchecklist( { forceMultiple: true
   , onComplete: function(selector) {
       var values = "";
       for( i=0; i < selector.options.length; i++ ) {
           if (selector.options[i].selected && (selector.options[i].value != "")) {
               if ( values != "" ) values += ";";
               values += selector.options[i].value;
           }
       }
       alert( values );
   }
   , onItemClick: function(checkbox, selector){
       var justChecked = checkbox.prop("checked");
       var checkCount = (justChecked) ? 1 : -1;
       for( i = 0; i < selector.options.length; i++ ){
           if ( selector.options[i].selected ) checkCount += 1;
       }
       if ( checkCount > 3 ) {
           alert( "Limit is 3" );
           throw "too many";
       }
   }
       });
 
Share this answer
 

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