Graphic Design ServicesandPortfoliobyPhillip DodsonofVisional Echoes
July 22, 2007 at 7:40 pm

CSS liberation. And other fun stuff.

» Filed Under » rants

Alright, I read something tonight that I have to share. It was written years ago, but it still applies, and I love it.

This article by Dave Shea really hits the CSS Compliance Police or CCP right where it hurts. (Yes, thats a term I made up)

It talks about… using… tables… for… presentation. I can already hear the police sirens. But seriously, read it… embrace it… and make it your own.

And to compound your pleasure, Dave Shea refers to an article by the accessibility maestro, Joe Clark himself, that when I read it, gave me the same butterflies in my stomach that I got while watching Maverick and Goose dogfighting against enemy MiGS.

Enjoy.

Oh, and by the way. If you disagree with my enthusiasm over these articles, keep it to yourself. Thank you.

Phil Dodson

July 7, 2007 at 7:08 pm

Query String Value Getter Function

» Filed Under » javascript

This function will take a query string (or use the current URI if no string is supplied) and return the value of the chosen argument.

Code

function GetQueryValue(k,q) // Key, Query String
{
   q=q||location.href;  // uses current uri if no query is supplied
   var tmpNdx=q.indexOf('?');
   if (tmpNdx!=-1) // If string has query information
   {
      q=q.slice(tmpNdx+1); // Remove all information except for query
      q=q.split('&');      // Create array of key/value pairs
      for (var i=0;i<q.length;i++)
      {
         var p=q[i].indexOf('=');
         if (p>0)
         {
            var thisk=q[i].substring(0,p);
            if (thisk==k) return q[i].substring(p+1); // return value
         }
      }
      return null; // If key doesn't exist, return null	
   } else {
      return null; // If no query information, return null
   }
}

Returns

  • string | value of argument if exists
  • null if argument doesn’t exist

Prototype

GetQueryValue(string key[, query string])

Note that the query string argument is optional. If no string is supplied, script will use the address of the page.

Samples

<script type="text/javascript" src="GetQueryValue.js"></script>   // include the script
<script type="text/javascript">
   var myStr='http://www.mywebsite.com?var1=foo&var2=bar';
 
   alert(GetQueryValue('var2',myStr));     // alerts bar
   alert(GetQueryValue('somevar',myStr));  // alerts null
   alert(GetQueryValue('myvar'));              //  Searches your current URI and returns myvar if it exists
</script>

Download

You can download the script here.

June 16, 2007 at 7:57 pm

FormElement Classes

» Filed Under » php

What does it do, exactly?

This FormElement object makes creating sticky forms in PHP rather easy.

I was looking for an easy way to make sticky forms in PHP without using clunky code chunks in the value attributes of my form elements. I’m sure there are numerous solutions for this, but hey, lets face it, it’s fun to learn new things! And I saw this as a perfect way to get my feet wet in Object Oriented Programming.

So after some work, here we have some classes that do just what I wanted. They create HTML input elements inside of a form while making these elements sticky, in the event of a validation error (or any other reason to post back the form values) occurs.

(more…)