Jul 102009
 

I just noticed this today. I monitor a number of sites and servers using the great Xymon system monitoring tool (Linky). It is based on early Big Brother code. Anyway, today I noticed that the graphs were all blue. Something like this:

Bad Xymon Graph

Bad Xymon Graph

I’m using Xymon 4.2.3 on the servers, and both servers show the graph like this using Firefox 3.5 on Linux. Google Chrome development version, SeaMonkey 1.1.5, Epiphany and Galeon all display the graph correctly.

I have no solution, but I thought I’d post my experience.

Jun 092009
 

I’ve been recently doing some Javascript coding and ran across an error in IE that I wasn’t noticing in Firefox (well…there are hundreds of these, but this one is a show stopper).

It is a small validation script for a form to do some checking before submitting.  It’s pretty simple, take a look:


function validateForm(){
	/*
	 * First, get the fields.
	 */
	var name = document.getElementById('name').value;
	var title = document.getElementById('title').value;
	var phone = document.getElementById('phone').value;
	var email = document.getElementById('email').value;
	var description = document.getElementById('description').value;
	var cost = document.getElementById('cost').value;
	//pic1 = document.getElementById('pic1').value;
	//pic2 = document.getElementById('pic2').value;
	if(name == ""){
		alert('You must enter your name.');
	}
	else if(title == ""){
		alert('You must enter give your ad a title.');
	}
	else if(phone == "" && email == ""){
		alert('You must enter a phone number or email address.');
	}
	else if(description == ""){
		alert('You must enter a description of the item you want to buy, sell or trade.');
	}
	else if(isNaN(cost)){
		alert('You must enter a numeric cost, without the $ symbol.');
	}
	else{
		document.getElementById('submit').style.display = 'block';
		alert('Please press the submit button below.');
	}
}

Executing the script on a blank form in FF would give the correct response, Enter in a name. In IE, I would get an error on Line 15 about Object Expected (in the script, line 15 is actually a commented out line, so that error isn’t very helpful).

I then remembered something about IE automatically creating variables from a form by the name/id of the form field on the page. Since my variable name, and field name were the same, it would try to compare its self created object against my test, instead of the variable that I was assigning, thus creating an error.

To work around this, I had to rename all of my variables (I could have also renamed all of my fields):


function validateForm(){
	/*
	 * First, get the fields.
	 */
	var bsname = document.getElementById('name').value;
	var bstitle = document.getElementById('title').value;
	var bsphone = document.getElementById('phone').value;
	var bsemail = document.getElementById('email').value;
	var bsdescription = document.getElementById('description').value;
	var bscost = document.getElementById('cost').value;
	//pic1 = document.getElementById('pic1').value;
	//pic2 = document.getElementById('pic2').value;
	if(bsname == ""){
		alert('You must enter your name.');
	}
	else if(bstitle == ""){
		alert('You must enter give your ad a title.');
	}
	else if(bsphone == "" && bsemail == ""){
		alert('You must enter a phone number or email address.');
	}
	else if(bsdescription == ""){
		alert('You must enter a description of the item you want to buy, sell or trade.');
	}
	else if(isNaN(bscost)){
		alert('You must enter a numeric cost, without the $ symbol.');
	}
	else{
		document.getElementById('submit').style.display = 'block';
		alert('Please press the submit button below.');
	}
}

After this, it runs fine in both browsers. I remember hitting my head off the wall for a LONG time when I originally encountered this error, so hopefully this will save someone else some time.