简体   繁体   中英

struts tag library - select tag

I have a dropdown list. When user click on the drop down list, I need to show first 4 items in the list and the scroll bar so that users can scroll and see the remaining items in the list.

Please find the dropdown list sample fiddle below. The same way as shown in fiddle when user click on the dropdown list, Option 1, Option 2, Option 3, Option 4 should be shown with the scrollbar to scroll and see remaining options in the list.

 <select> <option value="one">Option 1</option> <option value="two">Option 2</option> <option value="three">Option 3</option> <option value="four">Option 4</option> <option value="five">Option 5</option> <option value="siz">Option 6</option> <option value="seven">Option 7</option> <option value="eight">Option 8</option> </select> 

---EDITED---

The above code is not working in IE. In IE it's showing the scrollar but when i select the item from the dropdown list, an alert box is displayed with error message and i cannot select any date from the dropdown list. I tried to debug and see if any errors using developer tools, but there are no errors shown.

Internet Explorer has stopped working A problem caused the progrm to stop working correctly.Please close the program.

You can use onmousedown to dynamically expand the select list on click and onchange / onblur event handlers to go back:

 <select onmousedown="if (this.options.length > 4) this.size = 4;" onchange="this.size = 0;" onblur="this.size = 0;"> <option value="one">Option 1</option> <option value="two">Option 2</option> <option value="three">Option 3</option> <option value="four">Option 4</option> <option value="five">Option 5</option> <option value="siz">Option 6</option> <option value="seven">Option 7</option> <option value="eight">Option 8</option> </select> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM