开发者

Drop down list with large number of words in each selection

I have an unusual situation. I have a drop down list that allows my users to select one of a number of different scenarios. My problem is that each scenario is 开发者_JS百科about 100 words long. I want to show the user everything and a radio selection box would not be appropriate. What happens is that because of the very long rows my dropdown list appears so wide that it goes off the edge of the page.

Is there a way that I can split up text (I'm using C#) and add new lines so that dropdown list box contains "multi line" selections?

Hope this makes sense to you.


I don't think it's possible without some scripting. You can add width and white-space:pre-wrap to your select tag, but that only wraps the visible part. You can't, as Madmargigan suggested, use a title to show the complete string (the title won't show).

I have prepared a very basic script to demonstrate how you could do this with javascript. See this fiddle. It may give you ideas?


You cannot do this with the standard html dropdownlist. Some frameworks have workarounds for it (for instance, see ASP.NET's dropdownlist). There are also javascript libraries that offer solutions to this problem as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜