erdomester Posted May 29, 2009 Share Posted May 29, 2009 Hi! Is there any way to max the size of a dropdown box? If I use size=X, it becomes a listbox of a size=X. The ddbox visualizes 16 elements but i want only 10 max. erdomester Quote Link to comment https://forums.phpfreaks.com/topic/160193-max-size-of-dropdown-box/ Share on other sites More sharing options...
lonewolf217 Posted May 29, 2009 Share Posted May 29, 2009 a dropdown box to select a single element at a time, or a select multiple box ? You populate the box with however many elements you want, so why dont you just limit the number of options you put into the box rather than trying to limit the number it displays ? Quote Link to comment https://forums.phpfreaks.com/topic/160193-max-size-of-dropdown-box/#findComment-845177 Share on other sites More sharing options...
erdomester Posted May 29, 2009 Author Share Posted May 29, 2009 Single select. I dont get what you are saying. I have 190 elements in the dropdown box and when I click on the arrow (like here in the "Message icon" row: Standard), it "drops down" 16 elements. This is too many for me as I have not so much place on the website. Quote Link to comment https://forums.phpfreaks.com/topic/160193-max-size-of-dropdown-box/#findComment-845192 Share on other sites More sharing options...
lonewolf217 Posted May 29, 2009 Share Posted May 29, 2009 So basically what you are saying is that you have 190 elements available to select, the dropdown only shows 16 of them, and you want to only display 10 of them? How would you choose which 10 to select ? can you post the code of how you are generating this dropdown Quote Link to comment https://forums.phpfreaks.com/topic/160193-max-size-of-dropdown-box/#findComment-845210 Share on other sites More sharing options...
Axeia Posted May 29, 2009 Share Posted May 29, 2009 umm, you want to shrink the "dropdown" part of the <select> when clicked? I'm quite sure that isn't possible as <selects> are based on your operating systems settings. Quote Link to comment https://forums.phpfreaks.com/topic/160193-max-size-of-dropdown-box/#findComment-845234 Share on other sites More sharing options...
erdomester Posted May 29, 2009 Author Share Posted May 29, 2009 I want something like this: http://kepfeltoltes.hu/090529/ddbox_www.kepfeltoltes.hu_.jpg Quote Link to comment https://forums.phpfreaks.com/topic/160193-max-size-of-dropdown-box/#findComment-845265 Share on other sites More sharing options...
lonewolf217 Posted May 29, 2009 Share Posted May 29, 2009 then you have to limit the number of items you are sending to the dropdown. post your code Quote Link to comment https://forums.phpfreaks.com/topic/160193-max-size-of-dropdown-box/#findComment-845267 Share on other sites More sharing options...
GingerRobot Posted May 29, 2009 Share Posted May 29, 2009 You mean like the size attribute? Quote Link to comment https://forums.phpfreaks.com/topic/160193-max-size-of-dropdown-box/#findComment-845286 Share on other sites More sharing options...
lonewolf217 Posted May 29, 2009 Share Posted May 29, 2009 no, I think he is still wanting it to only display 1 value at a time, but the entire list only be 10 items. By using size=X it will just change the number of entries that are visible at a time the only question here is why limit to 10 possible choices if he is already putting 16+ choices into the list Quote Link to comment https://forums.phpfreaks.com/topic/160193-max-size-of-dropdown-box/#findComment-845298 Share on other sites More sharing options...
erdomester Posted May 29, 2009 Author Share Posted May 29, 2009 This is a simple html code, I am sorry i didn't pay attention.. something like this: echo '<select name="hour">'; for ($i=0; $i<24; $i++) { if ($i < 10) { $i = "0".$i; } echo "<option value='$i'>".$i."<?/option>"; } echo '</select>'; Yeah, sg like the size operator, looking for a maxsize or sg, but havent found anything and begin to think that there no html solution for this... Quote Link to comment https://forums.phpfreaks.com/topic/160193-max-size-of-dropdown-box/#findComment-845303 Share on other sites More sharing options...
lonewolf217 Posted May 29, 2009 Share Posted May 29, 2009 if this is your exact code then I am even more confused. 1) you say that it only displays 16 items .. in both IE and Firefox I see all 24 items 2) you say you only want it to show 10 items.... Why? You built your for loops to display all 24 items (hours ?). If you only want to show 10 then limit your for loop to whatever hours you want Can you try to provide exact details about what you are trying to accomplish here ? Quote Link to comment https://forums.phpfreaks.com/topic/160193-max-size-of-dropdown-box/#findComment-845309 Share on other sites More sharing options...
Psycho Posted May 29, 2009 Share Posted May 29, 2009 Wow, I think there is a LOT of confusion in this post. I *think* I understand the OP request, let me restate for clarity. The OP has a select list with 190 items in it. He only wants the user to select ONE item. However, when the user selects the drop-down arrow, the slect list expands into a scrolling list. That expanded list is big enough for 16 items to be viewable at a time. The OP would like that expanded list to only be big enough to have 10 items visibile at a time. I agree with Axeia above, I don't think it is possible. The length of the expanded box is controlled by the BROWSER. I did a test and it is different in IE & FF. I think the only way you can do what you want is by creting a JavaScript select list. Quote Link to comment https://forums.phpfreaks.com/topic/160193-max-size-of-dropdown-box/#findComment-845311 Share on other sites More sharing options...
GingerRobot Posted May 29, 2009 Share Posted May 29, 2009 I agree with Axeia above, I don't think it is possible. I disagree. If all you're looking to do is alter the number of elements you can see at one time, the size attribute is what you need. Quote Link to comment https://forums.phpfreaks.com/topic/160193-max-size-of-dropdown-box/#findComment-845314 Share on other sites More sharing options...
erdomester Posted May 29, 2009 Author Share Posted May 29, 2009 mjdamato: EXACTLY! So I shall make a javascript list? Quote Link to comment https://forums.phpfreaks.com/topic/160193-max-size-of-dropdown-box/#findComment-845317 Share on other sites More sharing options...
Axeia Posted May 29, 2009 Share Posted May 29, 2009 I'm still confused, but try this: echo '<select onfocus="this.size=2" onblur="this.size=null" name="hour">'; Very counter intuitive to use though. Quote Link to comment https://forums.phpfreaks.com/topic/160193-max-size-of-dropdown-box/#findComment-845336 Share on other sites More sharing options...
Psycho Posted May 29, 2009 Share Posted May 29, 2009 I agree with Axeia above, I don't think it is possible. I disagree. If all you're looking to do is alter the number of elements you can see at one time, the size attribute is what you need. The size attribute will make the select list "fixed" to that size. The OP wants a standard drop-down with only one item visible with an expander button and when expanded is only X items high. I'm still confused, but try this: echo '<select onfocus="this.size=2" onblur="this.size=null" name="hour">'; Very counter intuitive to use though. Ah, that's a good idea. I was going to advise against a custom select list, but that will work even for someone without JS. Quote Link to comment https://forums.phpfreaks.com/topic/160193-max-size-of-dropdown-box/#findComment-845346 Share on other sites More sharing options...
erdomester Posted May 30, 2009 Author Share Posted May 30, 2009 I'm still confused, but try this: echo '<select onfocus="this.size=2" onblur="this.size=null" name="hour">'; When I expand the ddbox, the whole webpage makes a jump then the ddbox becomes a fixed listbox. So when I want to use other ddboxes on the page, that one remains a listbox. But that is a great start:) Quote Link to comment https://forums.phpfreaks.com/topic/160193-max-size-of-dropdown-box/#findComment-845601 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.