-Ben
Sent from my BlackBerry
Sent from my BlackBerry
var a = location.search.slice(1).split("&"), GET = [];
for (i in a) { GET[a[i].split("=")[0]] = a[i].split("=")[1]; }http://example.com/index.html?id=1001&fname=Ben&lname=Bradley
alert("id = " + GET["id"]);
alert("first name = " + GET["fname"]);
alert("last name = " + GET["lname"]);
function isIP(obj) {
var ary = obj.value.split(".");
var ip = true;
for (var i in ary) { ip = (!ary[i].match(/^\d{1,3}$/) || (Number(ary[i]) > 255)) ? false : ip; }
ip = (ary.length != 4) ? false : ip;
if (!ip) { // the value is NOT a valid IP address
obj.style.background = "red";
obj.value = "Not a valid IP address";
obj.select();
} else { obj.style.background = ""; } // the value IS a valid IP address
}<input type="text" id="ip" onBlur="isIP(this)" />

function makeLink(str) {
var linkString = "";
var ary = str.split(" ");
var a=0;
while (a < ary.length) {
linkString += (ary[a].match("http")) ? ary[a].link(ary[a])+" " : ary[a]+" ";
a+=1;
}
return linkString;
}It's a web-based task management system that is based on Steven Covey's Urgency vs. Importance matrix.For the uninitiated, this matrix is simply a chart with four boxes, each with its own classification of urgent or not and important or not.
if (!Date.parse(variable)) {
alert("Not an acceptable date.");
return false;
}var today = new Date();
var Christmas = new Date("12-25-2009");
var diffMs = (Christmas - today); // milliseconds between now & Christmas
var diffDays = Math.round(diffMs / 86400000); // days
var diffHrs = Math.round((diffMs % 86400000) / 3600000); // hours
var diffMins = Math.round(((diffMs % 86400000) % 3600000) / 60000); // minutes
alert(diffDays + " days, " + diffHrs + " hours, " + diffMins + " minutes until Christmas 2009 =)");
alert(myArray['row3']['column4']);instead of
alert(myArray[2][3]);
var myArray = new Array();This will produce the following as output:
myArray['row1'] = { 'col1':'BLARGH!!!', 'col2':'HONK!!!!' }
myArray['row2'] = { 'col1':'FOO!!!', 'col2':'BAR!!!!' }
myArray['row3'] = { 'col1':'FOUR!!!', 'col2':'GREGS!!!' }
document.write(myArray['row2']['col1'] + " - " + myArray['row3']['col2']);
FOO!!! - GREGS!!!So hopefully my overuse of the keywords has helped rank this page high in the search algorithms and you've found my tip useful. Remember though, it's only really useful if you have a do while or for loop to populate the array.