<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
<channel>
<title>The Future of the Web</title>
<link>http://www.thefutureoftheweb.com/</link>
<description>JavaScript, CSS, HTML, and anything else of interest to standards-loving web designers and developers</description>
<pubDate>Mon, 09 Nov 2009 05:23:11 -0800</pubDate>
<language>en</language>
<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/thefutureoftheweb" type="application/rss+xml" /><feedburner:browserFriendly>This is an XML content feed. It is intended to be viewed in a newsreader or syndicated to another site, subject to copyright and fair use.</feedburner:browserFriendly><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item><title>jQuery Live Events</title><link>http://feedproxy.google.com/~r/thefutureoftheweb/~3/ZU6_dYeBA_0/jquery-live-events</link><guid isPermaLink="false">http://www.thefutureoftheweb.com/blog/jquery-live-events</guid><pubDate>Mon, 16 Feb 2009 13:39:55 -0800</pubDate><dc:creator>Jesse Skinner</dc:creator><comments>http://www.thefutureoftheweb.com/blog/jquery-live-events#comments</comments><category>javascript</category><description>&lt;p&gt;&lt;a href="http://docs.jquery.com/Release:jQuery_1.3"&gt;jQuery 1.3&lt;/a&gt; came out on January 14th, &lt;a href="http://blog.jquery.com/2009/01/21/jquery-131-released/"&gt;jQuery 1.3.1&lt;/a&gt; on the 21st, and with them we now have &lt;a href="http://docs.jquery.com/Events/live"&gt;live events&lt;/a&gt; built into jQuery.&lt;/p&gt;

&lt;p&gt;Live events are pretty magical at first glance. They allow you to set events only once, and they work forever in the future, even as you're creating new elements and adding them to the page.&lt;/p&gt;

&lt;p&gt;Normally if you ran:&lt;/p&gt;

&lt;pre&gt;
$('a.wizard').click(function(){
    // do some wizardry
});
&lt;/pre&gt;

&lt;p&gt;and then later you added wanted to add some more &lt;var&gt;&amp;lt;a class="wizard"&amp;gt;&lt;/var&gt;s to the page, you would have to re-attach this event handler over and over.&lt;/p&gt;

&lt;p&gt;Live events allow you to add an event that will work forever. This means you only have to add each type of event once. You would only have to write:&lt;/p&gt;

&lt;pre&gt;
$('a.wizard').live('click', function(){
    // do some wizardry
});
&lt;/pre&gt;

&lt;p&gt;And your wizard links will work forever, even after you add 100 new wizard links to the page dynamically.&lt;/p&gt;

&lt;p&gt;This magic trick works by attaching the click event to the document. Whenever you click anywhere on the page, the document click event gets called. jQuery compares the target element to your wizard links and triggers your click event if the click came from inside the link.&lt;/p&gt;

&lt;p&gt;You can also do this yourself using the new &lt;var&gt;closest()&lt;/var&gt; function. It allows you to do something like this:&lt;/p&gt;

&lt;pre&gt;
// listen for clicks on the document
$(document).click(function(e){
    // look for a possible parent element matching a.wizard
    $(e.target).closest('a.wizard').each(function(){
        // wizard it up
    });
});
&lt;/pre&gt;

&lt;p&gt;These live events can really help with performance. If you're attaching events to 100s of similar elements, like photos in an album, you can also save a lot of memory and speed things up by using live events, or using the example above and checking for events on a common parent element, either &lt;var&gt;document&lt;/var&gt; or any element.&lt;/p&gt;

&lt;p&gt;If you're used to using closures to use data within click handlers, you will find they won't work anymore which is probably a good thing. Instead, you can use &lt;var&gt;&lt;a href="http://docs.jquery.com/Data"&gt;data()&lt;/a&gt;&lt;/var&gt; to store any amount of data with that element and get it out later:&lt;/p&gt;

&lt;pre&gt;
// maybe this is some JSON data you got using Ajax or something
var wizards = [
   { name: 'Merlin', skill: 'magic' },
   { name: 'Mr. Wizard', skill: 'science' }
];

$.each(wizards, function(i, wizard){
    // create a new link, change the text, add the data and append to the body
    $('&amp;lt;a class="wizard"/&amp;gt;')
        .text(wizard.name)
        .data('wizard', wizard)
        .appendTo(document.body);
});
&lt;/pre&gt;

&lt;p&gt;then you only need to attach the click handler once:&lt;/p&gt;

&lt;pre&gt;
$(document).ready(function(){

    $('a.wizard').live('click', function(){
        // fetch the data back out
        var wizard = $(this).data('wizard');

        // get the stuff you need out of the object
        var name = wizard.name;
        var skill = wizard.skill;

        // do your thing
        alert(
            "Hello my name is "
            + name
            + "and I'm better than you at "
            + skill
            + "!!!"
        );
    });

});
&lt;/pre&gt;

&lt;p&gt;And you can actually do these things in reverse, the order doesn't matter because of the magic and universality of live events.&lt;/p&gt;

&lt;p&gt;Pretty cool, eh? This way of developing has always been possible using JavaScript, but after learning about this with jQuery 1.3, it changed the way I look at programming with data and events.&lt;/p&gt;

&lt;p&gt;What do you think? Any questions, corrections or suggestions? &lt;a href="http://www.thefutureoftheweb.com/blog/jquery-live-events#comment1"&gt;Leave a comment.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Tags:  &lt;a href='http://technorati.com/tag/javascript' rel='tag'&gt;javascript&lt;/a&gt; &lt;a href='http://technorati.com/tag/jquery' rel='tag'&gt;jquery&lt;/a&gt; &lt;a href='http://technorati.com/tag/1.3' rel='tag'&gt;1.3&lt;/a&gt; &lt;a href='http://technorati.com/tag/live' rel='tag'&gt;live&lt;/a&gt; &lt;a href='http://technorati.com/tag/events' rel='tag'&gt;events&lt;/a&gt; &lt;a href='http://technorati.com/tag/closest' rel='tag'&gt;closest&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=ggVSezcy"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?i=ggVSezcy" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=hwjhUoHE"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?i=hwjhUoHE" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=pgy5YFkU"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=bTrim7rg"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description><feedburner:origLink>http://www.thefutureoftheweb.com/blog/jquery-live-events</feedburner:origLink></item><item><title>I need web developers</title><link>http://feedproxy.google.com/~r/thefutureoftheweb/~3/Gfql-v0GArQ/i-need-web-developers</link><guid isPermaLink="false">http://www.thefutureoftheweb.com/blog/i-need-web-developers</guid><pubDate>Wed, 14 Jan 2009 12:35:48 -0800</pubDate><dc:creator>Jesse Skinner</dc:creator><comments>http://www.thefutureoftheweb.com/blog/i-need-web-developers#comments</comments><category>work</category><description>&lt;p&gt;I'm in need of a few good developers. I've put up a job posting at Authentic Jobs, &lt;a href="http://authenticjobs.com/jobs/3186/"&gt;PHP Web Developer / Project Manager&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;
&lt;p&gt;&lt;strong&gt;(Anywhere)&lt;/strong&gt; I'm looking for an individual (no teams) to help me lead web development projects. I need someone with lots of experience giving quotes and managing projects with other developers involved.&lt;/p&gt;	&lt;p&gt;You will be coding in the trenches, and need to be a master of PHP, MySQL, HTML, CSS, JavaScript and other web technologies.&lt;/p&gt;	&lt;p&gt;You should have a ton of experience with software development. You must write elegant code and be able to architect and implement beautiful, uncoupled, well tested software.&lt;/p&gt;	&lt;p&gt;You should be a web standards advocate, be familiar with unobtrusive techniques and understand the importance of creating high-quality, accessible web sites and applications.&lt;/p&gt;	&lt;p&gt;Your English should be impeccable and professional, both spoken and written.&lt;/p&gt;	&lt;p&gt;I need someone that can be available to work up to 30 hours per week, and be committed to helping out over the long term.&lt;/p&gt;	&lt;p&gt;If this sounds like you, and you want to take a lead on exciting web development projects, please contact me with the following stuff:&lt;/p&gt;	&lt;p&gt;1. Your hourly rate&lt;br /&gt; 
2. Your resume&lt;br /&gt; 
3. Your location&lt;br /&gt; 
4. Your weekly availability&lt;br /&gt; 
5. Your work experience&lt;br /&gt; 
6. Your expertise&lt;br /&gt; 
7. Type of projects you enjoy most
&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;If you'd like to work with me on cool projects, please &lt;a href="http://www.thefutureoftheweb.com/contact/me"&gt;contact me here&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Tags:  &lt;a href='http://technorati.com/tag/work' rel='tag'&gt;work&lt;/a&gt; &lt;a href='http://technorati.com/tag/hiring' rel='tag'&gt;hiring&lt;/a&gt; &lt;a href='http://technorati.com/tag/web' rel='tag'&gt;web&lt;/a&gt; &lt;a href='http://technorati.com/tag/developer' rel='tag'&gt;developer&lt;/a&gt; &lt;a href='http://technorati.com/tag/php' rel='tag'&gt;php&lt;/a&gt; &lt;a href='http://technorati.com/tag/jquery' rel='tag'&gt;jquery&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=RXsQDMUw"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?i=RXsQDMUw" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=UBtO5Tie"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?i=UBtO5Tie" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=9svzXCYA"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=5vMSav1p"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description><feedburner:origLink>http://www.thefutureoftheweb.com/blog/i-need-web-developers</feedburner:origLink></item><item><title>buttons need type="submit" to submit in IE</title><link>http://feedproxy.google.com/~r/thefutureoftheweb/~3/ITtN6DZYH1Y/button-wont-submit-in-ie</link><guid isPermaLink="false">http://www.thefutureoftheweb.com/blog/button-wont-submit-in-ie</guid><pubDate>Fri, 26 Dec 2008 14:29:42 -0800</pubDate><dc:creator>Jesse Skinner</dc:creator><comments>http://www.thefutureoftheweb.com/blog/button-wont-submit-in-ie#comments</comments><category>html</category><description>&lt;p&gt;In a typical round of doing Internet Explorer clean up at the end of a project, I had to figure out why my &lt;code&gt;&amp;lt;button&amp;gt;Submit&amp;lt;/button&amp;gt;&lt;/code&gt; wasn't submitting a form in IE.&lt;/p&gt;

&lt;p&gt;I did a search on "html button" and went to the &lt;a href="http://www.w3.org/TR/html401/interact/forms.html#h-17.5"&gt;w3c HTML 4.01 specifications&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;blockquote&gt;type = submit|button|reset [CI]&lt;br/&gt;
&lt;br/&gt;
This attribute declares the type of the button. Possible values:&lt;br/&gt;
&lt;br/&gt;
submit: Creates a submit button. This is the default value.&lt;br/&gt;
reset: Creates a reset button.&lt;br/&gt;
button: Creates a push button.
&lt;/blockquote&gt;&lt;/p&gt;

&lt;p&gt;So the default is submit. But Internet Explorer has obviously forgotten this in IE6 and IE7. I found it worked without type="submit" in Firefox, Safari, Chrome and Opera. I haven't tested in IE8 because I don't have it installed. Maybe someone wants to check it out? &lt;a href="http://www.thefutureoftheweb.com/demo/2008-12-26-button-submit"&gt;Here is a demo page.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So I guess we should get in the habit of using:&lt;/p&gt;

&lt;pre&gt;&amp;lt;button type="submit"&amp;gt;Submit&amp;lt;/button&amp;gt;&lt;/pre&gt;&lt;p&gt;Tags:  &lt;a href='http://technorati.com/tag/html' rel='tag'&gt;html&lt;/a&gt; &lt;a href='http://technorati.com/tag/ie' rel='tag'&gt;ie&lt;/a&gt; &lt;a href='http://technorati.com/tag/standards' rel='tag'&gt;standards&lt;/a&gt; &lt;a href='http://technorati.com/tag/w3c' rel='tag'&gt;w3c&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=AHR7TiSF"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?i=AHR7TiSF" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=lAkYj8UR"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?i=lAkYj8UR" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=hNHi6X3g"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=CGrIjio8"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description><feedburner:origLink>http://www.thefutureoftheweb.com/blog/button-wont-submit-in-ie</feedburner:origLink></item><item><title>Win $200 in a Web Dev Writing Contest</title><link>http://feedproxy.google.com/~r/thefutureoftheweb/~3/zmD4XElp_C8/win-200-bucks-in-a-web-contest</link><guid isPermaLink="false">http://www.thefutureoftheweb.com/blog/win-200-bucks-in-a-web-contest</guid><pubDate>Tue, 11 Nov 2008 09:41:05 -0800</pubDate><dc:creator>Jesse Skinner</dc:creator><comments>http://www.thefutureoftheweb.com/blog/win-200-bucks-in-a-web-contest#comments</comments><category>links</category><description>&lt;p&gt;Sometimes the hardest part of being an aspiring writer is coming up with a practical excuse for actually sitting down and writing an article.&lt;/p&gt;

&lt;p&gt;Contests to the rescue! &lt;a href="
http://www.serversidemagazine.com/news/write-articles-and-win-200-worth-amazon-gift-card"&gt;Server-Side Magazine is holding a contest for new articles.&lt;/a&gt; What better excuse to start writing than the chance of winning a $200 Amazon gift card, just in time to do some Christmas shopping? At the same time, you'll be getting a bit of practice and feedback, and exposure with fellow developers.&lt;/p&gt;

&lt;p&gt;You'd better hurry though - you'll need to craft a 1000-word-article about any PHP, Ruby or ASP.Net topic before November 27th, 2008!&lt;/p&gt;&lt;p&gt;Tags:  &lt;a href='http://technorati.com/tag/links' rel='tag'&gt;links&lt;/a&gt; &lt;a href='http://technorati.com/tag/contest' rel='tag'&gt;contest&lt;/a&gt; &lt;a href='http://technorati.com/tag/amazon' rel='tag'&gt;amazon&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=e2v7orrc"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?i=e2v7orrc" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=8cwnHvL5"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?i=8cwnHvL5" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=CDikxqXd"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=NqQlyeqZ"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description><feedburner:origLink>http://www.thefutureoftheweb.com/blog/win-200-bucks-in-a-web-contest</feedburner:origLink></item><item><title>Use Arrays in HTML Form Variables</title><link>http://feedproxy.google.com/~r/thefutureoftheweb/~3/Gm35QQ8GuQ4/use-arrays-with-html-form-inputs</link><guid isPermaLink="false">http://www.thefutureoftheweb.com/blog/use-arrays-with-html-form-inputs</guid><pubDate>Mon, 03 Nov 2008 16:59:22 -0800</pubDate><dc:creator>Jesse Skinner</dc:creator><comments>http://www.thefutureoftheweb.com/blog/use-arrays-with-html-form-inputs#comments</comments><category>html</category><description>&lt;p&gt;When you're dealing with processing forms, a lot of the time you have a one-to-one mapping of form fields and database columns, with perhaps an extra submit button or some fields that need special processing (eg. passwords).&lt;/p&gt;

&lt;p&gt;Although many frameworks like &lt;a href="http://codeigniter.com/"&gt;CodeIgniter&lt;/a&gt; make this easier, you can still easily come up with code like this:&lt;/p&gt;

&lt;pre&gt;
$this-&gt;db-&gt;insert('accounts', array(
    'first_name' =&gt; $this-&gt;input-&gt;post('first_name'),
    'last_name' =&gt; $this-&gt;input-&gt;post('last_name'),
    'email' =&gt; $this-&gt;input-&gt;post('email'),
    'address1' =&gt; $this-&gt;input-&gt;post('address1'),
    'address2' =&gt; $this-&gt;input-&gt;post('address2'),
    'city' =&gt; $this-&gt;input-&gt;post('city'),
    'state' =&gt; $this-&gt;input-&gt;post('state'),
    'zip' =&gt; $this-&gt;input-&gt;post('zip'),
    'phone' =&gt; $this-&gt;input-&gt;post('phone'),
    'fax' =&gt; $this-&gt;input-&gt;post('fax')
));
&lt;/pre&gt;

&lt;p&gt;See all that repetition? Whenever you see a group of lines that look almost the same, you know there is probably an opportunity to clean things up. Well luckily, there's a really neat one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You can create arrays in form fields using square brackets.&lt;/strong&gt; That means you can name fields like &lt;var&gt;account[first_name]&lt;/var&gt; and &lt;var&gt;account[last_name]&lt;/var&gt; and in most server-side languages, you will end up with an 'account' array.&lt;/p&gt;

&lt;p&gt;In HTML, PHP and CodeIgniter, that might look something like this:&lt;/p&gt;

&lt;pre&gt;
&amp;lt;input type="text" name="account[first_name]"/&amp;gt;
&amp;lt;input type="text" name="account[last_name]"/&amp;gt;
&amp;lt;!-- etc... --&amp;gt;
&amp;lt;input type="text" name="account[fax]"/&amp;gt;
&amp;lt;input type="submit" name="submit"/&amp;gt; &amp;lt;!-- note the lack of 'account' --&amp;gt;

// meanwhile, on the server...
$account = $this-&gt;input-&gt;post('account');

// VERY IMPORTANT: unset any fields that shouldn't be edited
unset($account['id']);

$this-&gt;db-&gt;insert('accounts', $account);
&lt;/pre&gt;

&lt;p&gt;See? Much cleaner. Yes, you do open a slight security hole potential, so be very careful when doing this on tables that have security implications, ie. user data. If you have an 'admin' column on your 'users' table, someone could maliciously add &lt;code&gt;&amp;lt;input type="hidden" name="users[admin]" value="1"/&amp;gt;&lt;/code&gt; to your form using &lt;a href="http://getfirebug.com"&gt;Firebug&lt;/a&gt; and grant themselves administration access. You can solve this by adding something like &lt;code&gt;unset($user['admin']);&lt;/code&gt; to the incoming data. If you wanted to be really safe, you could have an array of the keys you want to allow and filter against that using something like PHP's &lt;var&gt;array_intersect_key&lt;/var&gt; with &lt;var&gt;array_flip&lt;/var&gt;:&lt;/p&gt;

&lt;pre&gt;
$user = $this-&gt;input-&gt;post('user');

// only allow keys in $user to match the values in $columns
$columns = array('first_name', 'last_name', /* etc.. */ );
$user = array_intersect_key($user, array_flip($columns)));
&lt;/pre&gt;

&lt;p&gt;You can even do this with checkboxes and multiple select boxes, and alternatively leave out the key in the array to create a regular array (ie. not associative) of values:&lt;/p&gt;

&lt;pre&gt;
&amp;lt;label&amp;gt;&amp;lt;input type="checkbox" name="choice[]" value="1"/&amp;gt; 1&amp;lt;/label&amp;gt;
&amp;lt;label&amp;gt;&amp;lt;input type="checkbox" name="choice[]" value="2"/&amp;gt; 2&amp;lt;/label&amp;gt;
&amp;lt;!-- etc... --&amp;gt;

// meanwhile, on the server...
$choice = $this-&gt;input-&gt;post('choice');

print_r($choice); // Array ( [0] =&gt; 1 [1] =&gt; 2 )
&lt;/pre&gt;

&lt;p&gt;This "trick" can really clean your code up. I used it recently to drastically simplify a form that had a shipping address and billing address. If the user checked a box saying "My shipping and billing are the same", I was able to simply do something like this:&lt;/p&gt;

&lt;pre&gt;
$shipping = $_POST['shipping'];
$shipping_billing_same = $_POST['shipping_billing_same'];

if ($shipping_billing_same) {
    $billing = $shipping;
} else {
    $billing = $_POST['billing'];
}
&lt;/pre&gt;

&lt;p&gt;Much nicer than that 24 form fields that were hard-coded previously.&lt;/p&gt;

&lt;p&gt;I've given examples here in PHP and CodeIgniter. Does anyone else want to give examples in other server-side languages and frameworks?&lt;/p&gt;&lt;p&gt;Tags:  &lt;a href='http://technorati.com/tag/html' rel='tag'&gt;html&lt;/a&gt; &lt;a href='http://technorati.com/tag/php' rel='tag'&gt;php&lt;/a&gt; &lt;a href='http://technorati.com/tag/codeigniter' rel='tag'&gt;codeigniter&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=YYJe02KI"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?i=YYJe02KI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=nqbrym02"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?i=nqbrym02" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=5VLp6hju"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=ppVqmD8k"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description><feedburner:origLink>http://www.thefutureoftheweb.com/blog/use-arrays-with-html-form-inputs</feedburner:origLink></item><item><title>5 Reasons Freelancers Can Succeed in a Shrinking Economy</title><link>http://feedproxy.google.com/~r/thefutureoftheweb/~3/tKZSc0J-b7I/5-ways-freelancers-can-succeed-in-bad-economy</link><guid isPermaLink="false">http://www.thefutureoftheweb.com/blog/5-ways-freelancers-can-succeed-in-bad-economy</guid><pubDate>Fri, 24 Oct 2008 12:27:35 -0700</pubDate><dc:creator>Jesse Skinner</dc:creator><comments>http://www.thefutureoftheweb.com/blog/5-ways-freelancers-can-succeed-in-bad-economy#comments</comments><category>work</category><description>&lt;p&gt;Like many people, I've been a bit obsessed about the economy lately. I'm wasn't sure whether or not to be scared, and to be honest I still don't. But I did think of some reasons freelancing might be a safe place to be.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;You have a diversified clientele.&lt;/strong&gt;
Your clients can be anywhere in the world, and you have many of them. And if you're lucky, you have more than enough work to fill your time. No matter how bad the economy gets, there should still be some business available.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You have very little overhead.&lt;/strong&gt;
For most freelancers, all you need to work is a laptop and the Internet, both of which you'd probably have even if you weren't freelancing. You probably pay $10/month for your web site hosting, but otherwise you don't have a reason to borrow money. The gears of the credit crunch don't touch your business.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You can drop your prices whenever you want.&lt;/strong&gt;
If you find less people can afford what you're charging, you'll be able to adjust accordingly. If you have a job and they decide they can't afford you, then you get laid off.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Internet is the place to be for self-employed professionals.&lt;/strong&gt;
With the considerably low cost of having the Internet, I would assume that a lot more business will happen online as more people become self-employed and work from home. The number of people you can potentially connect with online feels infinite.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Businesses who don't want employees might turn to freelancers.&lt;/strong&gt;
Who knows, maybe in uncertain times, more business will want to hire freelancers on a contract basis rather than dedicate to hiring an employee they don't know if they'll be able to keep.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For those of you who don't freelance, I'm not suggesting you quit your job and start freelancing tomorrow. You'll have to decide that for yourself. If you want to start freelancing, I would suggest is to get the ball rolling on the side while you have a job. Get that website up and get some presence on the Internet. That way you'll have something to fall back on if you lose your job.&lt;/p&gt;

&lt;p&gt;So things don't look too bad for us freelancers. How about you? Have you noticed the shrinking economy having a direct effect on your business or job? What do you think we can expect?&lt;/p&gt;
&lt;p&gt;Tags:  &lt;a href='http://technorati.com/tag/work' rel='tag'&gt;work&lt;/a&gt; &lt;a href='http://technorati.com/tag/freelancing' rel='tag'&gt;freelancing&lt;/a&gt; &lt;a href='http://technorati.com/tag/economy' rel='tag'&gt;economy&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=DPtyUawY"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?i=DPtyUawY" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=P5xGcTno"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?i=P5xGcTno" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=2OfVDss4"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=NQIb01GG"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description><feedburner:origLink>http://www.thefutureoftheweb.com/blog/5-ways-freelancers-can-succeed-in-bad-economy</feedburner:origLink></item><item><title>Keeping a Live Eye on Logs</title><link>http://feedproxy.google.com/~r/thefutureoftheweb/~3/TFrGKyRLUxw/watching-logs-with-tail</link><guid isPermaLink="false">http://www.thefutureoftheweb.com/blog/watching-logs-with-tail</guid><pubDate>Wed, 22 Oct 2008 16:58:58 -0700</pubDate><dc:creator>Jesse Skinner</dc:creator><comments>http://www.thefutureoftheweb.com/blog/watching-logs-with-tail#comments</comments><category>server</category><description>&lt;p&gt;In web development, you can get really used to getting good error messages. If you're coding in PHP, you come to rely on the web server telling you if a variable is undefined or a file is missing.&lt;/p&gt;

&lt;p&gt;Likewise, when you're debugging, sometimes the easiest sanity check is to output some text. You'll find me using &lt;var&gt;echo "wtf?"; die;&lt;/var&gt; quite often when I'm trying to figure out why a block of code isn't being executed.&lt;/p&gt;

&lt;p&gt;But sometimes, even these rudimentary methods of developing aren't available to you. Maybe error messages are turned off on the web server you're stuck debugging. Or maybe you have a lot of Ajax requests flying around and are tired of peeking at the result of each request.&lt;/p&gt;

&lt;p&gt;Log files to the rescue. Nearly every framework and server has logging functionality. Apache usually logs every request, so you can see when images, static files, and other requests are made. CodeIgniter has several levels of logging, including DEBUG, ERROR and INFO. Whatever framework you use, or if you're using one you built yourself, you'll probably find some way of writing log messages to a file.&lt;/p&gt;

&lt;p&gt;And if you have a log file that's being updated, you have a way of watching things happen in real time. I'm not talking about opening up the log file every now and then and looking back through it, I'm talking about watching it being updated as it happens.&lt;/p&gt;

&lt;p&gt;Let's say you have a web server running Linux and are trying to debug something using CodeIgniter. You SSH into the web server, find the log file, and &lt;var&gt;tail -f&lt;/var&gt; it. &lt;var&gt;tail&lt;/var&gt; is a command which will dump the end of a file out for you. If you add the &lt;var&gt;-f&lt;/var&gt; parameter, it will "follow" the file, printing out any new lines as they are added to the log file.&lt;/p&gt;

&lt;pre&gt;
$ cd thefutureoftheweb.com/system/logs
$ tail -f log-2008-10-23.php
&lt;/pre&gt;

&lt;p&gt;If you're working locally on Windows, make sure you have &lt;a href="http://www.cygwin.com/"&gt;Cygwin&lt;/a&gt; installed. (Cygwin gives you a Linux-style console in Windows so you can do awesome stuff like this.) If so, you should have or be able to use &lt;var&gt;tail&lt;/var&gt; in the exact same way. Mac and Linux users should have &lt;var&gt;tail&lt;/var&gt; installed already.&lt;/p&gt;

&lt;p&gt;Back at my old job, we used to keep console windows open using &lt;var&gt;tail&lt;/var&gt; to watch the live web servers, &lt;em&gt;especially&lt;/em&gt; after an update. This way we could see errors appearing to users &lt;em&gt;live&lt;/em&gt; and could investigate and solve problems that would otherwise a) get buried in the logs, or b) go completely unnoticed.&lt;/p&gt;

&lt;p&gt;It can really help to get in the groove of having one or two terminal windows open &lt;var&gt;tail&lt;/var&gt;ing the logs of the servers you're currently working on. And then if you get the urge to write &lt;code&gt;echo "wtf?"; die;&lt;/code&gt; you can instead write &lt;code&gt;log_message('info', 'wtf?');&lt;/code&gt; (or equivalent in your framework of choice).&lt;/p&gt;

&lt;p&gt;For further information, check out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.ss64.com/bash/tail.html"&gt;tail man page&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codeigniter.com/user_guide/general/errors.html"&gt;CodeIgniter Error Handling&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Happy &lt;var&gt;tail&lt;/var&gt;ing!&lt;/p&gt;&lt;p&gt;Tags:  &lt;a href='http://technorati.com/tag/server' rel='tag'&gt;server&lt;/a&gt; &lt;a href='http://technorati.com/tag/tail' rel='tag'&gt;tail&lt;/a&gt; &lt;a href='http://technorati.com/tag/linux' rel='tag'&gt;linux&lt;/a&gt; &lt;a href='http://technorati.com/tag/ajax' rel='tag'&gt;ajax&lt;/a&gt; &lt;a href='http://technorati.com/tag/codeigniter' rel='tag'&gt;codeigniter&lt;/a&gt; &lt;a href='http://technorati.com/tag/apache' rel='tag'&gt;apache&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=QTPoExy7"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?i=QTPoExy7" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=F2uKMmlx"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?i=F2uKMmlx" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=eP6RRAcL"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=Iw078tBW"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description><feedburner:origLink>http://www.thefutureoftheweb.com/blog/watching-logs-with-tail</feedburner:origLink></item><item><title>Using PHP's empty() Instead of isset() and count()</title><link>http://feedproxy.google.com/~r/thefutureoftheweb/~3/8mHlsrw6l2k/using-php-empty-instead-of-isset-count</link><guid isPermaLink="false">http://www.thefutureoftheweb.com/blog/using-php-empty-instead-of-isset-count</guid><pubDate>Mon, 20 Oct 2008 07:20:01 -0700</pubDate><dc:creator>Jesse Skinner</dc:creator><comments>http://www.thefutureoftheweb.com/blog/using-php-empty-instead-of-isset-count#comments</comments><category>php</category><description>&lt;p&gt;I often work with data arrays in PHP as a way to pass information around or store information in sessions. When you work with these, you can't always assume that all properties are defined. I had some conditional logic code in PHP that was only supposed to execute if an array contained any values:&lt;/p&gt;

&lt;pre&gt;
$data = array(
   'text' =&gt; array( 'hello', 'world' ),
   'numbers' =&gt; array( 43, 2, 55 )
);

if (count($data['text'])) {
   // do something with $data['text']
}
&lt;/pre&gt;

&lt;p&gt;But then I was in a situation where &lt;var&gt;$data['text']&lt;/var&gt; may or may not be defined. So I was going to update my &lt;var&gt;if&lt;/var&gt; statement like so:&lt;/p&gt;

&lt;pre&gt;
if (isset($data['text']) &amp;amp;&amp;amp; count($data['text'])) {
   // do something
}
&lt;/pre&gt;

&lt;p&gt;But that looks kind of messy. I don't really like &lt;var&gt;isset()&lt;/var&gt; but it is a necessary evil to avoid "Undefined" errors. Or is it?&lt;/p&gt;

&lt;pre&gt;
if (!empty($data['text'])) {
   // do something
}
&lt;/pre&gt;

&lt;p&gt;&lt;var&gt;empty()&lt;/var&gt; to the rescue - it returns true if &lt;var&gt;$data['text']&lt;/var&gt; is undefined, or if it is an empty array, or if it is &lt;var&gt;false&lt;/var&gt; or &lt;var&gt;null&lt;/var&gt; or &lt;var&gt;0&lt;/var&gt;. So &lt;var&gt;!empty()&lt;/var&gt; is what I'm &lt;em&gt;really&lt;/em&gt; trying to determine, and it works great.&lt;/p&gt;

&lt;p&gt;For more info, see: &lt;a href="http://php.net/empty"&gt;empty() at PHP.net&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Tags:  &lt;a href='http://technorati.com/tag/php' rel='tag'&gt;php&lt;/a&gt; &lt;a href='http://technorati.com/tag/syntax' rel='tag'&gt;syntax&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=deDgwP0F"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?i=deDgwP0F" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=B2bDT0OU"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?i=B2bDT0OU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=gJu41UwX"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=cAqOWXLP"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description><feedburner:origLink>http://www.thefutureoftheweb.com/blog/using-php-empty-instead-of-isset-count</feedburner:origLink></item><item><title>Testing Web Pages with Lynx</title><link>http://feedproxy.google.com/~r/thefutureoftheweb/~3/97o3npR9RRU/testing-web-sites-in-lynx-browser</link><guid isPermaLink="false">http://www.thefutureoftheweb.com/blog/testing-web-sites-in-lynx-browser</guid><pubDate>Sun, 19 Oct 2008 18:32:55 -0700</pubDate><dc:creator>Jesse Skinner</dc:creator><comments>http://www.thefutureoftheweb.com/blog/testing-web-sites-in-lynx-browser#comments</comments><category>browsers</category><description>&lt;p&gt;If you're not familiar, &lt;a href="http://lynx.isc.org/"&gt;Lynx&lt;/a&gt; is the most basic web browser, found on Unix and Linux servers. There are no photos, just pure text, links and forms.&lt;/p&gt;

&lt;p&gt;You're probably wondering why you would ever think about supporting a browser that's based in a console window. Does anyone actually browse the web from a bash shell?&lt;/p&gt;

&lt;p&gt;Basically, here's the benefit: if you know it works in Lynx, you know it works everywhere. Lynx doesn't have JavaScript or CSS available, and there are no images. It doesn't get more limited than that.&lt;/p&gt;

&lt;p&gt;And actually, a lot of the traffic to your site is viewing things in this HTML-only form. I'm talking about search-engine spiders, bots, and people stuck using text-only devices such as screen readers.&lt;/p&gt;

&lt;p&gt;So run through your site with Lynx now and then. You will be able to see at a glance if there is enough hidden or alternate text on the page to be useful to search engines and the blind. You'll also be able to ensure that forms and functionality are available to absolutely everyone, even people browsing under Bash!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Update: I just discovered &lt;a href="http://seebot.org/"&gt;Seebot&lt;/a&gt;, a web app which lets you browse the web the same text-only way Lynx (and bots) do.&lt;/em&gt;&lt;/p&gt;&lt;p&gt;Tags:  &lt;a href='http://technorati.com/tag/browsers' rel='tag'&gt;browsers&lt;/a&gt; &lt;a href='http://technorati.com/tag/html' rel='tag'&gt;html&lt;/a&gt; &lt;a href='http://technorati.com/tag/lynx' rel='tag'&gt;lynx&lt;/a&gt; &lt;a href='http://technorati.com/tag/testing' rel='tag'&gt;testing&lt;/a&gt; &lt;a href='http://technorati.com/tag/accessibility' rel='tag'&gt;accessibility&lt;/a&gt; &lt;a href='http://technorati.com/tag/seo' rel='tag'&gt;seo&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=ggOPT9Fg"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?i=ggOPT9Fg" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=oqbhfa0l"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?i=oqbhfa0l" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=YqHQp4yu"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=zGjJDzO3"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description><feedburner:origLink>http://www.thefutureoftheweb.com/blog/testing-web-sites-in-lynx-browser</feedburner:origLink></item><item><title>Stop CSS Background Flickering in Internet Explorer 6</title><link>http://feedproxy.google.com/~r/thefutureoftheweb/~3/6kNLvW4Wk-0/stop-background-flashing-in-ie6</link><guid isPermaLink="false">http://www.thefutureoftheweb.com/blog/stop-background-flashing-in-ie6</guid><pubDate>Sat, 18 Oct 2008 15:56:51 -0700</pubDate><dc:creator>Jesse Skinner</dc:creator><comments>http://www.thefutureoftheweb.com/blog/stop-background-flashing-in-ie6#comments</comments><category>javascript</category><description>&lt;p&gt;I was once again reminded of an IE6 bug I had forgotten about - background images flashing or flickering when the mouse hovers over them.&lt;/p&gt;

&lt;p&gt;So, I went looking for a solution. &lt;a href="http://www.mister-pixel.com/"&gt;Here's what I found&lt;/a&gt;:&lt;/p&gt;

&lt;pre&gt;
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(e) {}
&lt;/pre&gt;

&lt;p&gt;Works like a charm. Turns out it's due to the browser not caching the background images. This command turns on background image caching.&lt;/p&gt;

&lt;p&gt;Do you think this would be good code to add to the core jQuery library?&lt;/p&gt;&lt;p&gt;Tags:  &lt;a href='http://technorati.com/tag/javascript' rel='tag'&gt;javascript&lt;/a&gt; &lt;a href='http://technorati.com/tag/css' rel='tag'&gt;css&lt;/a&gt; &lt;a href='http://technorati.com/tag/ie6' rel='tag'&gt;ie6&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=NhiFSMWW"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?i=NhiFSMWW" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=aHAzbIpK"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?i=aHAzbIpK" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=HvFTIXR9"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/thefutureoftheweb?a=tg12ypV4"&gt;&lt;img src="http://feeds.feedburner.com/~f/thefutureoftheweb?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description><feedburner:origLink>http://www.thefutureoftheweb.com/blog/stop-background-flashing-in-ie6</feedburner:origLink></item></channel>
</rss>
