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

Show dropdown on entering text

1 Answer 34 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Tina
Top achievements
Rank 1
Tina asked on 29 Jun 2012, 02:02 AM
I want to make the dropdown show only when user types anything in the input from client side?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Jun 2012, 04:56 AM
Hi Tina,

Try the following Javascript to achieve your scenario.

JS:
<script type="text/javascript">
      var x = 0;
      function OnClientDropDownOpening(sender, args)
    {
         if (sender.get_text().length == 0)
         {
             if (x == 0)
             {
                 args.set_cancel(true);
             }
             else
             {
                 x = 0;
             }
         }
    }
    function OnClientKeyPressing(sender, args)
    {
         var val = args._domEvent.keyCode;
         if (((val > 95) && (val < 106)) || ((val > 64) && (val < 91)))
         {
             x = 1;
             sender.showDropDown();
         }
    }

Thanks,
Princy.
Tags
ComboBox
Asked by
Tina
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or