开发者

Tabulating an option of a select tag

开发者 https://www.devze.com 2022-12-11 07:49 出处:网络
I am currently developing a Struts (1.3.10) application and I\'m trying to show in a combo box a set of data. Every single option(row) is a String created 开发者_C百科by the union of 3 different Strin

I am currently developing a Struts (1.3.10) application and I'm trying to show in a combo box a set of data. Every single option(row) is a String created 开发者_C百科by the union of 3 different Strings.

My question is if it's possible to tabulate that information in every option from the combo box, to show the information like the example you can see here:

Data1 | Data2 | Data3  
DataLargerThan1 | Data2 | DataLargerThan3  
DataMuchLargerThan1| DataLargerThan2 | Data3

it should be

Data1               | Data2           | Data3  
DataLargerThan1     | Data2           | DataLargerThan3  
DataMuchLargerThan1 | DataLargerThan2 | Data3

Is this possible? I'm trying to show formatted data with the pre tag, but I haven't got any result yet.

Thanks in advance, Carlos


Best what you can do is to use non breaking spaces instead of normal spaces. That however require a precise knowledge of the font width in advance. It's the easiest in combination with a monospaced font as every character has a fixed width.

Example:

<select style="font-family: monospace;">
    <option>Data1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;Data2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;Data3</option>
    <option>DataLargerThan1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;Data2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;DataLargerThan3</option>
    <option>DataMuchLargerThan1&nbsp;|&nbsp;DataLargerThan2&nbsp;|&nbsp;Data3</option>
</select>
0

精彩评论

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

关注公众号