Fetch the Web -- Homepage
Working together for your benefit

Archive for January, 2008

Javascript Cascading Form Values - part 2

Saturday, January 19th, 2008

A few weeks ago, I started a simple tutorial on how to cascade JavaScript check boxes from one row to the next in order to simplify the manipulation of large forms. This week, I’ll take it a step further by adding the same ability to both drop downs and text fields.

I’ve created a small example to help illustrate the functionality of the cascade. Once you load the cascade example page and click the down arrow next to a text field. It should change all the values in the text fields below to the same value as appears in the text box you clicked. The same can be done in the active column. Change one of the values in the active column to True and then click the down arrow next to it and all the rows below will change to True.

Without further discussion, here’s the Javascript code:

function cascSelect(theElement) {
var theForm = theElement.form;
var startBox = theElement.name;
for(z=0; z

if(theForm[z].type == ‘checkbox’ && theForm[z].name != ‘checkall’){
var checkNames = theForm[z].name;
if(checkNames == startBox.replace(/casca/, ‘checkeddelete’)) {
var startValue = (theForm[z].checked);
var startKey = z;
}
if (z > startKey) {
theForm[z].checked = startValue;
}
}
}
}
function cascScore(theElement) {
var theForm = theElement.form;
var startBox = theElement.name;
for(z=0; z
if(theForm[z].type == ‘text’){
var checkNames = theForm[z].name;
var tmp = startBox.replace(/cascScore/, ”);
tmp += ’score’;
if(checkNames == tmp) {
var startValue = (theForm[z].value);
var startKey = z;
}
if(theForm[z].name.match(/[0-9]score/)) {
if (z > startKey) {
theForm[z].value = startValue;
}
}
}
}
}
function selectTrueFalse(theElement) {
var theForm = theElement.form;
var startBox = theElement.name;
for(z=0; z
if(theForm[z].type == ’select-one’){
var checkNames = theForm[z].name;
var tmp = startBox.replace(/selectTrueFalse/, ”);
tmp += ‘active’;
if(checkNames == tmp) {
var startValue = (theForm[z].value);
var startKey = z;
}
if(theForm[z].name.match(/[0-9]active/)) {
if (z > startKey) {
theForm[z].value = startValue;
}
}
}
}
}
The only thing you have to watch for is the naming scheme. I was pretty lazy when I put all of this together and so it doesn’t follow any clean schema so to speak. Make sure the form fields have the same name as the JavaScript functions and you should be set.

Hope this helps some of you out, like I said before it may have saved me a few hours of work had I known it existed previously. It can be cleaned up quite a bit and I know all three functions could be lumped together into a more dynamic function if you like, but I’m not going to trouble with that here.

Cheers! Charles :-)

Creating visual styles for OpenAds text advertisements

Monday, January 7th, 2008

Recently I had a project where I was aked to add visual styls to Openads in an effort to create text that were similar in style to Google’s Adsense ads. Openads is an ads server or an extended banner rotator which allows for stats and all kinds of other features. I won’t get into it, if you need an adserver or want to know more, visit the Openads site directly.

Setting up the text ad is fairly simple. Click on Inventory, Advertisers, Choose the advertiser, Choose or Create a new campaign and then click on add a new banner. I’m hoping you know how to get to that point, otherwise give me a shout and I’ll be happy walk you through it.

Choose “Text Ad” from the dropdown box and you the page will look something like this:openads text banner

Ok, so now in the big trextarea, lets insert the following:

<font color="blue"><strong>How To Kill Bed Bugs</strong></font>
Kill Bed Bugs with Strei-Fab Spray Buy Now from Nixalite.com
<font color="green">www.nixalite.com/bedbugs.asp</font>

This should end up looking like this when all is said and done:
How To Kill Bed Bugs
Kill Bed Bugs with Strei-Fab Spray Buy Now from Nixalite.com
www.nixalite.com/bedbugs.asp

Now when we publish the text link, just place it in 200px div and voila, you have a sudo adsense text advertisement.

Analytics changes urchin.js to the new and improved ga.js

Friday, January 4th, 2008

First off, I’d like to wish a happy new year to all of you. I hope that this year is even better than last, and I must admit that last was very good for me!

Alrighty, so one of my clients took my advice and asked me to implement the new ga.js tracking cookie on his site. I didn’t pay much attention to what had changed, and just uploaded the new code without thinking about it. Google offers upgrade, they must insure backwards compatibility right?!?! Naw, that would be way too simple, instead they decide to take Microsoft’s lead and nerf backwards compatibility.

Ok, great, it doesn’t work so how do we fix it? Well, in this case, my client re-directs links to other sites. These redirects are driven via database driven backend and tend to change often enough that they shouldn’t be (and aren’t) hardcoded. To capture these clicks in analytics (which we compare to our own tracking system and notice a less than 5% difference) we used the following in our links:

onClick="javascript:urchinTracker('/outgoing/uniqueID_or_Title');"

and then changed it to

onClick="javascript:pageTracker._trackPageview('/outgoing/uniqueID_or_Title');"

So how will it work out? Hopefully all will be fine and our data will once again be tracked by analytics… if not I’ll let you guys know. BTW: You can find the information on google here: (for both versions of the tracking code)

GA Tracker (new)

Urchin Tracker (old)

:-) Charles