<?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>jasonackerman.com &#187; Geekery</title>
	<atom:link href="http://www.jasonackerman.com/category/geekery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jasonackerman.com</link>
	<description></description>
	<lastBuildDate>Thu, 08 Dec 2011 16:40:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Captain Obvious is Obvious</title>
		<link>http://www.jasonackerman.com/2011/01/24/captain-obvious-is-obvious/</link>
		<comments>http://www.jasonackerman.com/2011/01/24/captain-obvious-is-obvious/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 22:13:58 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Geekery]]></category>
		<category><![CDATA[document.form]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[option]]></category>
		<category><![CDATA[value]]></category>

		<guid isPermaLink="false">http://www.jasonackerman.com/?p=402</guid>
		<description><![CDATA[Perhaps those more seasoned than I in the ways of javascript already know this &#8211; but I just spent 2 hours trying to fix a javascript problem that ended up having a very easy solution. My google searches came up &#8230; <a href="http://www.jasonackerman.com/2011/01/24/captain-obvious-is-obvious/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[            <script type="text/javascript" src="http://www.jasonackerman.com/wp-content/plugins/wordpress-code-snippet/scripts/shBrushJScript.js"></script>
            <script type="text/javascript" src="http://www.jasonackerman.com/wp-content/plugins/wordpress-code-snippet/scripts/shBrushXml.js"></script>
<p>Perhaps those more seasoned than I in the ways of javascript already know this &#8211; but I just spent 2 hours trying to fix a javascript problem that ended up having a very easy solution. My google searches came up fruitless &#8211; partially because I was using search terms to describe symptoms that I thought were related to a completely different problem &#8211; but fruitless nonetheless.</p>
<p>Here&#8217;s the issue. I have a simple javascript form on a hotel website &#8211; you fill in your check-in date, check-out date, number of adults and number of children, and rather than process the data and actually search, the form just builds a simple URL string and passes it off to their main corporate site (in this case, Doubletree) to use their massive internal booking engine. Easy right? All I have to do is come up with a URL string, put together with variables from the form, in a function that runs with the onClick event on the submit button &#8211; the form never actually submits. Take that URL string, throw it into a window.location, and off we go. Elegant? Notsomuch. Effective? Youbetcha.</p>
<p>Here&#8217;s the javascript:</p>
<p><pre class="brush: js">function res_form() {
       
    	var rdir = &quot;http://secure.hilton.com/en/dt/res/choose_dates.jhtml?ctyhocn=DENCHDT&amp;arrivalDay=&quot;+document.resform.arriveDate.value+&quot;&amp;arrivalMonth=&quot;
+document.resform.arriveMonth.value+&quot;&amp;arrivalYear=&quot;+document.resform.arriveYear.value+
&quot;&amp;departureDay=&quot;+document.resform.departDate.value+&quot;&amp;departureMonth=&quot;+
document.resform.departMonth.value+&quot;&amp;departureYear=&quot;+document.resform.departYear.value
+&quot;&amp;numAdults=&quot;+document.resform.HowManyAdults.value+&quot;&amp;numChildren=&quot;+
document.resform.HowManyChildren.value;

window.location = rdir;
};</pre></p>
<p>Simple, right? Problem is, the adults field and the children field were not getting their values passed through. Well, that&#8217;s not accurate &#8211; Firefox/Safari/Chrome were putting the values for number of adults and children in the correct places &#8211; in other words, document.form.adults.value was coming out correctly. However, in IE &#8211; (oh, boy, here we go) &#8211; this was not happening. These values were empty, which pretty much killed the URL string and the Doubletree site didn&#8217;t know what to do with it and just threw a blank screen back at me.</p>
<p>After much consternation and googling and bad words rattling about in my head, I decided to pick apart the form itself, piece by piece, since most of this code was something I inherited from another firm. What I found was that while non-IE browsers will take the actual value in a field and store it as document.form.field.value, IE needs a more explicit kick in the teeth, and requires that the &#8216;value&#8217; attribute in the HTML&lt;option&gt; element be set.</p>
<p>So what I had was:</p>
<p><pre class="brush: xml">&lt;select name=&quot;HowManyAdults&quot; class=&quot;month&quot; id=&quot;HowManyAdults&quot;&gt;
        &lt;option selected=&quot;selected&quot;&gt;1&lt;/option&gt;
        &lt;option&gt;2&lt;/option&gt;
         &lt;option&gt;3&lt;/option&gt;
         &lt;option&gt;4&lt;/option&gt;
         &lt;option&gt;5&lt;/option&gt;
         &lt;option&gt;6&lt;/option&gt;
         &lt;option&gt;7&lt;/option&gt;
         &lt;option&gt;8&lt;/option&gt;
        &lt;option&gt;9&lt;/option&gt;
         &lt;option&gt;10&lt;/option&gt;
&lt;/select&gt;</pre></p>
<p>Firefox and Chrome likey, IE no likey. What I needed was:</p>
<p><pre class="brush: xml">&lt;select name=&quot;HowManyAdults&quot; class=&quot;month&quot; id=&quot;HowManyAdults&quot;&gt;
        &lt;option value=&quot;1&quot; selected=&quot;selected&quot;&gt;1&lt;/option&gt;
        &lt;option value=&quot;2&quot;&gt;2&lt;/option&gt;
        &lt;option value=&quot;3&quot;&gt;3&lt;/option&gt;
        &lt;option value=&quot;4&quot;&gt;4&lt;/option&gt;
        &lt;option value=&quot;5&quot;&gt;5&lt;/option&gt;
        &lt;option value=&quot;6&quot;&gt;6&lt;/option&gt;
        &lt;option value=&quot;7&quot;&gt;7&lt;/option&gt;
        &lt;option value=&quot;8&quot;&gt;8&lt;/option&gt;
        &lt;option value=&quot;9&quot;&gt;9&lt;/option&gt;
        &lt;option value=&quot;10&quot;&gt;10&lt;/option&gt;
      &lt;/select&gt;</pre></p>
<p>Everyone&#8217;s happy. </p>
<p>A very simple HTML solution to what appeared to be a javascript problem. I was convinced that those form elements were getting pushed through as null or something &#8211; but they weren&#8217;t, they just didn&#8217;t have a valid explicit value set to them, so IE had nothing to assign to them, whereas Firefox took the intuitive step of actually taking the value within the &lt;option&gt; tag, and making that the value.</p>
<p>So there you go. Probably a &#8220;duh&#8221; moment&#8230; I&#8217;m ticked that it took me two hours to figure it out, but hopefully my little odyssey helps someone else.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jasonackerman.com/2011/01/24/captain-obvious-is-obvious/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mobs and Mobility</title>
		<link>http://www.jasonackerman.com/2010/11/02/mobs-and-mobility/</link>
		<comments>http://www.jasonackerman.com/2010/11/02/mobs-and-mobility/#comments</comments>
		<pubDate>Wed, 03 Nov 2010 02:01:16 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Geekery]]></category>

		<guid isPermaLink="false">http://www.jasonackerman.com/?p=376</guid>
		<description><![CDATA[Anyone who knows me knows that I kinda make a big deal about a open source stuff&#8230; I run linux on my laptop, android on my hone, and generally prefer to stick to the free, open source model as much &#8230; <a href="http://www.jasonackerman.com/2010/11/02/mobs-and-mobility/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[            <script type="text/javascript" src="http://www.jasonackerman.com/wp-content/plugins/wordpress-code-snippet/scripts/shBrushJScript.js"></script>
            <script type="text/javascript" src="http://www.jasonackerman.com/wp-content/plugins/wordpress-code-snippet/scripts/shBrushXml.js"></script>
<p>Anyone who knows me knows that I kinda make a big deal about a open source stuff&#8230; I run linux on my laptop, android on my hone, and generally prefer to stick to the free, open source model as much as possible.</p>
<p>Well, between having a few clients starting to ask about iPad and iphone compatibility, and a really sad state of the market for alternative pad devices (chrome os or android?Who knows&#8230;), it seemed like the best move for a foray into larger touch devices was to go ahead and get an iPad. </p>
<p>The ipad is my first apple device. I am still not an apple fan, and there are certainly things that irritate me, but the reality is that the apple devices dominate the market, and I have a hunch that the pad device market will more accurately resemble the mp3 player market, as opposed to the smartphone market. That is to say, i don&#8217;t think android tablets will follow the lead of the android phones&#8230; The ipad, like the ipod, is going to stay dominant in the market. </p>
<p>So here i am, blogging from an ipad and enjoying the functional mobility of the masses. </p>
<p>I still prefer android and linux though, because I am stubborn like that.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jasonackerman.com/2010/11/02/mobs-and-mobility/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>State Select List for WordPress Custom Post Type</title>
		<link>http://www.jasonackerman.com/2010/10/19/state-select-list-for-wordpress-custom-post-type/</link>
		<comments>http://www.jasonackerman.com/2010/10/19/state-select-list-for-wordpress-custom-post-type/#comments</comments>
		<pubDate>Tue, 19 Oct 2010 23:43:52 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Geekery]]></category>

		<guid isPermaLink="false">http://www.jasonackerman.com/?p=368</guid>
		<description><![CDATA[I don&#8217;t usually blog about this stuff, but during the day I spend my time picking around WordPress trying to come up with new and cool ways to use it, both for myself and for my clients. Today, I was &#8230; <a href="http://www.jasonackerman.com/2010/10/19/state-select-list-for-wordpress-custom-post-type/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[            <script type="text/javascript" src="http://www.jasonackerman.com/wp-content/plugins/wordpress-code-snippet/scripts/shBrushJScript.js"></script>
            <script type="text/javascript" src="http://www.jasonackerman.com/wp-content/plugins/wordpress-code-snippet/scripts/shBrushXml.js"></script>
            <script type="text/javascript" src="http://www.jasonackerman.com/wp-content/plugins/wordpress-code-snippet/scripts/shBrushPhp.js"></script>
<p>I don&#8217;t usually blog about this stuff, but during the day I spend my time picking around WordPress trying to come up with new and cool ways to use it, both for myself and for my clients. Today, I was working on a custom plugin that required me to build a select list for all 50 of the United States. This was a bit tedious, so I&#8217;m offering up the code block as it is for you to use if you&#8217;d like. The only purpose here is to give you a block of code and save you some typing. Perhaps there&#8217;s a better way to build this list, but probably not. If you ever need a drop-down list of states to choose from in your WP custom post type or plugin, here&#8217;s a block you can start with. Now you&#8217;ll see that I have it checking for &#8220;my_fields&#8221; &#8230; I&#8217;ve dumped all of the fields for that custom post type into an array, then I&#8217;m checking to see if one of them has been saved so it keeps the correct one selected. There&#8217;s plenty more code to accomplish those functions, but this little doozy just has the <code><br />
<option></option>
<p></code> tags filled out for all 50 states. It should at least give you a good starting point. And since it&#8217;s long, you&#8217;ll have to click on the &#8220;Continue Reading&#8221; link to get to the code snippet. I&#8217;ll field any questions in the comments section if I can, but you&#8217;re better off just waiting until the plugin is complete and released into the wild, then you can have the whole thing!</p>
<p><span id="more-368"></span></p>
<p><pre class="brush: php">&lt;?	
// Alabama: AL
	echo '&lt;option value=&quot;AL&quot;';
         if ($my_fields['region'] == AL) echo 'selected=&quot;selected&quot;';
    echo '&gt;Alabama&lt;/option&gt;';
// Alaska: AK
	echo '&lt;option value=&quot;AK&quot;';
         if ($my_fields['region'] == AK) echo 'selected=&quot;selected&quot;';
    echo '&gt;Alaska&lt;/option&gt;';
// Arizona: AZ
	echo '&lt;option value=&quot;AZ&quot;';
         if ($my_fields['region'] == AZ) echo 'selected=&quot;selected&quot;';
    echo '&gt;Arizona&lt;/option&gt;';
// Arkansas: AR
	echo '&lt;option value=&quot;AR&quot;';
         if ($my_fields['region'] == AR) echo 'selected=&quot;selected&quot;';
    echo '&gt;Arkansas&lt;/option&gt;';
// California: CA
	echo '&lt;option value=&quot;CA&quot;';
         if ($my_fields['region'] == CA) echo 'selected=&quot;selected&quot;';
    echo '&gt;California&lt;/option&gt;';
// Colorado: CO
	echo '&lt;option value=&quot;CO&quot;';
         if ($my_fields['region'] == CO) echo 'selected=&quot;selected&quot;';
    echo '&gt;Colorado&lt;/option&gt;';
// Connecticut: CT
	echo '&lt;option value=&quot;CT&quot;';
         if ($my_fields['region'] == CT) echo 'selected=&quot;selected&quot;';
    echo '&gt;Connecticut&lt;/option&gt;';
// Delaware: DE
	echo '&lt;option value=&quot;DE&quot;';
         if ($my_fields['region'] == DE) echo 'selected=&quot;selected&quot;';
    echo '&gt;Delaware&lt;/option&gt;';
// Florida: FL
	echo '&lt;option value=&quot;FL&quot;';
         if ($my_fields['region'] == FL) echo 'selected=&quot;selected&quot;';
    echo '&gt;Florida&lt;/option&gt;';
// Georgia: GA
	echo '&lt;option value=&quot;GA&quot;';
         if ($my_fields['region'] == GA) echo 'selected=&quot;selected&quot;';
    echo '&gt;Georgia&lt;/option&gt;';
// Hawaii: HI
	echo '&lt;option value=&quot;HI&quot;';
         if ($my_fields['region'] == HI) echo 'selected=&quot;selected&quot;';
    echo '&gt;Hawaii&lt;/option&gt;';
// Idaho: ID
	echo '&lt;option value=&quot;ID&quot;';
         if ($my_fields['region'] == ID) echo 'selected=&quot;selected&quot;';
    echo '&gt;Idaho&lt;/option&gt;';
// Illinois: IL
	echo '&lt;option value=&quot;IL&quot;';
         if ($my_fields['region'] == IL) echo 'selected=&quot;selected&quot;';
    echo '&gt;Illinois&lt;/option&gt;';
// Indiana: IN
	echo '&lt;option value=&quot;IN&quot;';
         if ($my_fields['region'] == IN) echo 'selected=&quot;selected&quot;';
    echo '&gt;Indiana&lt;/option&gt;';
// Iowa: IA
	echo '&lt;option value=&quot;IA&quot;';
         if ($my_fields['region'] == IA) echo 'selected=&quot;selected&quot;';
    echo '&gt;Iowa&lt;/option&gt;';
// Kansas: KS
	echo '&lt;option value=&quot;KS&quot;';
         if ($my_fields['region'] == KS) echo 'selected=&quot;selected&quot;';
    echo '&gt;Kansas&lt;/option&gt;';
// Kentucky: KY
	echo '&lt;option value=&quot;KY&quot;';
         if ($my_fields['region'] == KY) echo 'selected=&quot;selected&quot;';
    echo '&gt;Kentucky&lt;/option&gt;';
// Louisiana: LA
	echo '&lt;option value=&quot;LA&quot;';
         if ($my_fields['region'] == LA) echo 'selected=&quot;selected&quot;';
    echo '&gt;Louisiana&lt;/option&gt;';
// Maine: ME
	echo '&lt;option value=&quot;ME&quot;';
         if ($my_fields['region'] == ME) echo 'selected=&quot;selected&quot;';
    echo '&gt;Maine&lt;/option&gt;';
// Maryland: MD
	echo '&lt;option value=&quot;MD&quot;';
         if ($my_fields['region'] == MD) echo 'selected=&quot;selected&quot;';
    echo '&gt;Maryland&lt;/option&gt;';
// Massachusetts: MA
	echo '&lt;option value=&quot;MA&quot;';
         if ($my_fields['region'] == MA) echo 'selected=&quot;selected&quot;';
    echo '&gt;Massachusetts&lt;/option&gt;';
// Michigan: MI
	echo '&lt;option value=&quot;MI&quot;';
         if ($my_fields['region'] == MI) echo 'selected=&quot;selected&quot;';
    echo '&gt;Michigan&lt;/option&gt;';
// Minnesota: MN
	echo '&lt;option value=&quot;MN&quot;';
         if ($my_fields['region'] == MN) echo 'selected=&quot;selected&quot;';
    echo '&gt;Minnesota&lt;/option&gt;';
// Mississippi: MS
	echo '&lt;option value=&quot;MS&quot;';
         if ($my_fields['region'] == MS) echo 'selected=&quot;selected&quot;';
    echo '&gt;Mississippi&lt;/option&gt;';
// Missouri: MO
	echo '&lt;option value=&quot;MO&quot;';
         if ($my_fields['region'] == MO) echo 'selected=&quot;selected&quot;';
    echo '&gt;Missouri&lt;/option&gt;';
// Montana: MT
	echo '&lt;option value=&quot;MT&quot;';
         if ($my_fields['region'] == MT) echo 'selected=&quot;selected&quot;';
    echo '&gt;Montana&lt;/option&gt;';
// Nebraska: NE
	echo '&lt;option value=&quot;NE&quot;';
         if ($my_fields['region'] == NE) echo 'selected=&quot;selected&quot;';
    echo '&gt;Nebraska&lt;/option&gt;';
// Nevada: NV
	echo '&lt;option value=&quot;NV&quot;';
         if ($my_fields['region'] == NV) echo 'selected=&quot;selected&quot;';
    echo '&gt;Nevada&lt;/option&gt;';
// New Hampshire: NH
	echo '&lt;option value=&quot;NH&quot;';
         if ($my_fields['region'] == NH) echo 'selected=&quot;selected&quot;';
    echo '&gt;New Hampshire&lt;/option&gt;';
// New Jersey: NJ
	echo '&lt;option value=&quot;NJ&quot;';
         if ($my_fields['region'] == NJ) echo 'selected=&quot;selected&quot;';
    echo '&gt;New Jersey&lt;/option&gt;';
// New Mexico: NM
	echo '&lt;option value=&quot;NM&quot;';
         if ($my_fields['region'] == NM) echo 'selected=&quot;selected&quot;';
    echo '&gt;New Mexico&lt;/option&gt;';
// New York: NY
	echo '&lt;option value=&quot;NY&quot;';
         if ($my_fields['region'] == NY) echo 'selected=&quot;selected&quot;';
    echo '&gt;New York&lt;/option&gt;';
// North Carolina: NC
	echo '&lt;option value=&quot;NC&quot;';
         if ($my_fields['region'] == NC) echo 'selected=&quot;selected&quot;';
    echo '&gt;North Carolina&lt;/option&gt;';
// North Dakota: ND
	echo '&lt;option value=&quot;ND&quot;';
         if ($my_fields['region'] == ND) echo 'selected=&quot;selected&quot;';
    echo '&gt;North Dakota&lt;/option&gt;';
// Ohio: OH
	echo '&lt;option value=&quot;OH&quot;';
         if ($my_fields['region'] == OH) echo 'selected=&quot;selected&quot;';
    echo '&gt;Ohio&lt;/option&gt;';
// Oklahoma: OK
	echo '&lt;option value=&quot;OK&quot;';
         if ($my_fields['region'] == OK) echo 'selected=&quot;selected&quot;';
    echo '&gt;Oklahoma&lt;/option&gt;';
// Oregon: OR
	echo '&lt;option value=&quot;OR&quot;';
         if ($my_fields['region'] == OR) echo 'selected=&quot;selected&quot;';
    echo '&gt;Oregon&lt;/option&gt;';
// Pennsylvania: PA
	echo '&lt;option value=&quot;PA&quot;';
         if ($my_fields['region'] == PA) echo 'selected=&quot;selected&quot;';
    echo '&gt;Pennsylvania&lt;/option&gt;';
// Rhode Island: RI
	echo '&lt;option value=&quot;RI&quot;';
         if ($my_fields['region'] == RI) echo 'selected=&quot;selected&quot;';
    echo '&gt;Rhode Island&lt;/option&gt;';
// South Carolina: SC
	echo '&lt;option value=&quot;SC&quot;';
         if ($my_fields['region'] == SC) echo 'selected=&quot;selected&quot;';
    echo '&gt;South Carolina&lt;/option&gt;';
// South Dakota: SD
	echo '&lt;option value=&quot;SD&quot;';
         if ($my_fields['region'] == SD) echo 'selected=&quot;selected&quot;';
    echo '&gt;South Dakota&lt;/option&gt;';
// Tennessee: TN
	echo '&lt;option value=&quot;TN&quot;';
         if ($my_fields['region'] == TN) echo 'selected=&quot;selected&quot;';
    echo '&gt;Tennessee&lt;/option&gt;';
// Texas: TX
	echo '&lt;option value=&quot;TX&quot;';
         if ($my_fields['region'] == TX) echo 'selected=&quot;selected&quot;';
    echo '&gt;Texas&lt;/option&gt;';
// Utah: UT
	echo '&lt;option value=&quot;UT&quot;';
         if ($my_fields['region'] == UT) echo 'selected=&quot;selected&quot;';
    echo '&gt;Utah&lt;/option&gt;';
// Vermont: VT
	echo '&lt;option value=&quot;VT&quot;';
         if ($my_fields['region'] == VT) echo 'selected=&quot;selected&quot;';
    echo '&gt;Vermont&lt;/option&gt;';
// Virginia: VA
	echo '&lt;option value=&quot;VA&quot;';
         if ($my_fields['region'] == VA) echo 'selected=&quot;selected&quot;';
    echo '&gt;Virginia&lt;/option&gt;';
// Washington: WA
	echo '&lt;option value=&quot;WA&quot;';
         if ($my_fields['region'] == WA) echo 'selected=&quot;selected&quot;';
    echo '&gt;Washington&lt;/option&gt;';
// West Virginia: WV
	echo '&lt;option value=&quot;WV&quot;';
         if ($my_fields['region'] == WV) echo 'selected=&quot;selected&quot;';
    echo '&gt;West Virginia&lt;/option&gt;';
// Wisconsin: WI
	echo '&lt;option value=&quot;WI&quot;';
         if ($my_fields['region'] == WI) echo 'selected=&quot;selected&quot;';
    echo '&gt;Wisconsin&lt;/option&gt;';
// Wyoming: WY	
	echo '&lt;option value=&quot;WY&quot;';
         if ($my_fields['region'] == WY) echo 'selected=&quot;selected&quot;';
    echo '&gt;Wyoming&lt;/option&gt;';
?&gt;</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jasonackerman.com/2010/10/19/state-select-list-for-wordpress-custom-post-type/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

