开发者

Tabulating an option of a select tag

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜