<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sean Gates' Blog &#187; HTML</title>
	<atom:link href="http://www.seangates.com/category/web-development/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.seangates.com</link>
	<description>By the looks of it {he thinks} he knows what he's doing.</description>
	<lastBuildDate>Sat, 10 Jul 2010 21:22:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Columns in Select Boxes</title>
		<link>http://www.seangates.com/2007/03/23/columns-in-select-boxes/</link>
		<comments>http://www.seangates.com/2007/03/23/columns-in-select-boxes/#comments</comments>
		<pubDate>Fri, 23 Mar 2007 20:17:44 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.seangates.com/?p=36</guid>
		<description><![CDATA[I came across a problem yesterday where I needed to create columns in select boxes. My issue revolved around showing an ID in the left column, and a description of the ID in the right column. This is due to the fact that people in our organization know most things by their ID, but my [...]]]></description>
			<content:encoded><![CDATA[<p>I came across a problem yesterday where I needed to create columns in select boxes.  My issue revolved around showing an ID in the left column, and a description of the ID in the right column.  This is due to the fact that people in our organization know most things by their ID, but my not know how to distinguish between similar IDs.  The ids are alphanumeric.  For example: SYS2007.  This could mean &#8220;System 2007&#8243;.  Then there could be one called SYS2007B.  Similar, but different.</p>
<p>So, I searched the web and found nothing about doing it in HTML or CSS (I figured as much but gave it a shot anyway).  Then I came up with this idea: use a fixed width font and fill in missing spaces.  So, I made the select box use courier.</p>
<pre>&lt;select ... style="font-family: courier;"&gt;</pre>
<p>Then I set about populating the box (using PHP of course) and came up with a small tidbit to fill in the extra spaces:</p>
<pre>formatID($id){</pre>
<pre>$str_length = strlen($id);</pre>
<pre>for($i=0; $i&lt;(15-$str_length); $i++){</pre>
<pre>$add_spaces = $add_spaces . ' ';</pre>
<pre>}</pre>
<pre>return $id . $add_spaces;</pre>
<pre>}</pre>
<p>Now, I use the function when looping through and building the select box:</p>
<pre>foreach($ps as $p){</pre>
<pre>echo '&lt;option id="' . $p-&gt;ID . '"</pre>
<pre>value="' . $p-&gt;ID . '"&gt;' .</pre>
<pre>formatSCN($p-&gt;ID) . $p-&gt;Title .</pre>
<pre>'&lt;/option&gt;';</pre>
<pre>}</pre>
<p>So, now what comes out is a column at the front that is formatted with a fixed width of characters.  Now you could do this if you wanted to format any number of columns, and not just the first. It may be cool if this showed 5 or 10+ columns of data.  But, that may be a usability issue.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seangates.com/2007/03/23/columns-in-select-boxes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
