Dropdown max size

Hi,

I need to make dropdown to open with max 10 in size when user selects the dropdown. If I use size attribute as 10 then dropdown remains open. Please advise.
Sample dropdown code below:

 <select id="selectcurrency" class="form-control formdoropdwon currencydropdownselect" onchange="updateCurrency(this);">
        <option value="0">Select currency</option>
        <option value="AED" currcode="AED" currname="United Arab Emirates Dirham(AED)">AED-United Arab Emirates Dirham(AED)</option>
        <option value="AUD" currcode="AUD" currname="Australian Dollar(AUD)">AUD-Australian Dollar(AUD)</option>
        <option value="USD" currcode="USD" currname="Us Dollar(USD)">USD-Us Dollar(USD)</option>
        <option value="AFN" currcode="AFN" currname="Afghani(AFN)">AFN-Afghani(AFN)</option>
        <option value="DZD" currcode="DZD" currname="Algerian Dinar(DZD)">DZD-Algerian Dinar(DZD)</option>
        <option value="ARS" currcode="ARS" currname="Argentine Peso(ARS)">ARS-Argentine Peso(ARS)</option>
        <option value="AZM" currcode="AZM" currname="Azerbaijan Manat(AZM)">AZM-Azerbaijan Manat(AZM)</option>
        <option value="BHD" currcode="BHD" currname="Bahraini Dinar(BHD)">BHD-Bahraini Dinar(BHD)</option>
        <option value="BDT" currcode="BDT" currname="Bangladesh Taka(BDT)">BDT-Bangladesh Taka(BDT)</option>
        <option value="BBD" currcode="BBD" currname="Barbados Dollar(BBD)">BBD-Barbados Dollar(BBD)</option>
        <option value="BMD" currcode="BMD" currname="Bermudian Dollar (Bermuda Dollar)(BMD)">BMD-Bermudian Dollar (Bermuda Dollar)(BMD)</option>
        <option value="BWP" currcode="BWP" currname="Botswana Pula(BWP)">BWP-Botswana Pula(BWP)</option>
        <option value="BRL" currcode="BRL" currname="Brazilian Real(BRL)">BRL-Brazilian Real(BRL)</option>
        <option value="BND" currcode="BND" currname="Brunei Dollar(BND)">BND-Brunei Dollar(BND)</option>
        <option value="BGN" currcode="BGN" currname="Bulgarian Lev(BGN)">BGN-Bulgarian Lev(BGN)</option>
        <option value="CAD" currcode="CAD" currname="Canadian Dollar(CAD)">CAD-Canadian Dollar(CAD)</option>
        <option value="GHC" currcode="GHC" currname="Cedi(GHC)">GHC-Cedi(GHC)</option>
        <option value="XOF" currcode="XOF" currname="Cfa Franc Bceao(XOF)">XOF-Cfa Franc Bceao(XOF)</option>
        

    </select>

Open in new window


Regards,
Dinesh BaliAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Paul JacksonSoftware EngineerCommented:
There is no property to restrict the number of items shown in a dropdown, it is determined by the browser/operating system and will generally vary from user to user depending on the resolution they are using and other factors.
1
Dinesh BaliAuthor Commented:
Are you sure? Can I have some article on this please?

I just need dropdown size to be upto 10 and then scrollbar should come.
So that user can select the items.
0
David S.Commented:
We're sure. There are just styling limitations to a lot of form controls. As an alternative for a plain <select>, you could use Awesomplete.
0
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

Dinesh BaliAuthor Commented:
Many Thanks

This is autocomplete textbox.
I need user should be able to select from dropdown as well.
I don't mind if the dropdown is editable and user can also write text.
But dropdown is must,

Please advise.
0
lenamtlCommented:
Hi,

You can use Select2 for this https://select2.org/dropdown
This is flexible and full of features

You can set the CSS value instead of  item limit
https://select2.org/appearance
0
leakim971PluritechnicianCommented:
test page : http://jsfiddle.net/4whj295t/

jQuery(function($) {
	$("#fakeselectcurrency").hover(function() {
		$("#selectcurrency").show();  
  },
  function() {
		$("#selectcurrency").hide();    
  });
  $("#selectcurrency").change(function() {
  	$(":text[name='selectcurrency']").val(currency.value);
  });
});

Open in new window


#selectcurrency {
  display:none;
}
#textcurrency {
  width:295px;
}

Open in new window


<div id="fakeselectcurrency">
  <input type="text" value="Select currency" name="selectcurrency" id="textcurrency" />
  <br/>
  <select id="selectcurrency" class="form-control formdoropdwon currencydropdownselect" multiple="multiple" size="10">
        <option value="AED" currcode="AED" currname="United Arab Emirates Dirham(AED)">AED-United Arab Emirates Dirham(AED)</option>
        <option value="AUD" currcode="AUD" currname="Australian Dollar(AUD)">AUD-Australian Dollar(AUD)</option>
        <option value="USD" currcode="USD" currname="Us Dollar(USD)">USD-Us Dollar(USD)</option>
        <option value="AFN" currcode="AFN" currname="Afghani(AFN)">AFN-Afghani(AFN)</option>
        <option value="DZD" currcode="DZD" currname="Algerian Dinar(DZD)">DZD-Algerian Dinar(DZD)</option>
        <option value="ARS" currcode="ARS" currname="Argentine Peso(ARS)">ARS-Argentine Peso(ARS)</option>
        <option value="AZM" currcode="AZM" currname="Azerbaijan Manat(AZM)">AZM-Azerbaijan Manat(AZM)</option>
        <option value="BHD" currcode="BHD" currname="Bahraini Dinar(BHD)">BHD-Bahraini Dinar(BHD)</option>
        <option value="BDT" currcode="BDT" currname="Bangladesh Taka(BDT)">BDT-Bangladesh Taka(BDT)</option>
        <option value="BBD" currcode="BBD" currname="Barbados Dollar(BBD)">BBD-Barbados Dollar(BBD)</option>
        <option value="BMD" currcode="BMD" currname="Bermudian Dollar (Bermuda Dollar)(BMD)">BMD-Bermudian Dollar (Bermuda Dollar)(BMD)</option>
        <option value="BWP" currcode="BWP" currname="Botswana Pula(BWP)">BWP-Botswana Pula(BWP)</option>
        <option value="BRL" currcode="BRL" currname="Brazilian Real(BRL)">BRL-Brazilian Real(BRL)</option>
        <option value="BND" currcode="BND" currname="Brunei Dollar(BND)">BND-Brunei Dollar(BND)</option>
        <option value="BGN" currcode="BGN" currname="Bulgarian Lev(BGN)">BGN-Bulgarian Lev(BGN)</option>
        <option value="CAD" currcode="CAD" currname="Canadian Dollar(CAD)">CAD-Canadian Dollar(CAD)</option>
        <option value="GHC" currcode="GHC" currname="Cedi(GHC)">GHC-Cedi(GHC)</option>
        <option value="XOF" currcode="XOF" currname="Cfa Franc Bceao(XOF)">XOF-Cfa Franc Bceao(XOF)</option>
    </sele

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jquery-ui

From novice to tech pro — start learning today.