Author Archive

Dynamically Colouring The Active Select List Item With JQuery/Ajax/PHP

I had a job recently where the customer wanted the items in a select list to be colour coded. My initial thought was just to use jquery and have it set the background of the selected item using the $(‘#myselect’).changed() function. The plan was that in the change event I would check the background colour of the newly selected item and then change the background colour of the select control. I wasn’t able to get the item colour though, even though the items were displaying with the various background colours – when I queried the CSS background-color attribute with jquery it would always return the same colour which was a shade of blue. I suspect it was the default colour that you see when you mouse over an item in the drop down list.

My solution was to use ajax to get the colour code for the item and then set the background colour for the list. A side effect of this was that it would set all items in the list which didn’t already have a specific background colour (some didn’t have a colour code), so I had to set each of those to #ffffff.

Here is the code and an example:

HTML Code:

In the project I was working on, we have a table that has a list of the items and the corresponding background colour. We query the table and set the background-color style attribute dynamically. For the purpose of the example I’ve simply added these manually.

<select name="selectlist" id="selectlist">
<option value="1" style="background-color:#ff0000;">The First Item 1</option>
<option value="2" style="background-color:#00ff00;">The Second Item</option>
<option value="3" style="background-color:#ffffff;">The Third Item</option>
<option value="4" style="background-color:#0000ff;">The Fourth Item</option>
</select>
Javascript Code:

We start by initialising the select list to display the correct colour for the default selected item and then we hook the .changed() event.

$(document).ready(function() {

	// Initialise the select list
	selitem=$('#selectlist :selected').val();
	$.get('/examples/ajax-functions.php?item='+selitem, function(data) {
		if(data != '')
		{
			$('#selectlist').css('background-color', data);
		}
		else
		{
			$('#selectlist').css('background-color', '#fff');
		}
	});

	// Colour code select list
	$('#selectlist').change(function(){
		selitem=$('#selectlist :selected').val();
		$.get('/examples/ajax-functions.php?item='+selitem, function(data) {
			if(data != '')
			{
				$('#selectlist').css('background-color', data);
			}
			else
			{
				$('#selectlist').css('background-color', '#fff');
			}
		});
	});
});
PHP Code:

I use a simple switch statement to get the correct background color – in the project
I queried a MySQL database and used the result from the database table.

<?
 if(isset($_GET["item"]) && is_numeric($_GET["item"]))
 {
 get_select_bg($_GET["item"]);
 }

 function get_select_bg($itemid)
 {
 switch($itemid)
 {
 case 1:
 $selbg='#ff0000';
 break;
 case 2:
 $selbg='#00ff00';
 break;
 case 3:
 $selbg='#ffffff';
 break;
 case 4:
 $selbg='#0000ff';
 break;
 default:
 break;
 }

 echo $selbg;
 }
?>

That’s about all there is to it!

WebAssist Customers Are Revolting

I guess WebAssist must have had a fairly full inbox after the recent changes to their support area. I received two followup emails that they sent to customers basically saying that due to the feedback they received, they had decided to return the peer to peer forum to its former glory and the paid support would be optional. Here is the most recent email:

It’s been quite an interesting couple of days here as we have rolled out updates to our support system. We have had overwhelmingly feedback that you like our old forum system so we wanted to let you know that we’ve put that system back in place. Our support team will be answering your questions in the forums just like they have in the past.

We will also continue to have paid-for options for customers who want guaranteed response times or to set up a phone appointment with one of our Technical Support Engineers. This should satisfy the demand we’ve been hearing for this type of support. Paid tickets and Premier appointments will ensure that you are able to resolve your issues in a timely fashion so that you can meet your deadlines.

Lastly, I wanted to thank everyone for their continued feedback. As you can imagine, not all of the feedback has been good over the past few days but I am impressed by the passion that you have shown for what we do. I hope that we have been able to show you that we do listen and that we do care about our community. I look forward to the next few months as we launch exciting new products that you will hopefully find useful and will help you be successful on the web.

I have to say that I’m pleased and a little releived that they decided to roll back those changes. WebAssist make some really classy DreamWeaver addons and they’ve always had that ‘pass me some pizza and a can of Jolt’ feel about them… programming geeks who make cool tools for other programming geeks. It would be a real shame if they destroyed that connection they have with developers.

Anyway, a big thumbs up from me and thanks for listening to your customers, WebAssist!

WebAssist – Putting Greed Before Need

I’ve used WebAssist products for several years now. They sell a number of Dreamweaver extensions such as eCart, DataAssist and Dynamic Web Charts. A recent ‘support improvement’ has changed my opinion of them from a switched on development company to just another greedy corporation that’s trying to squeeze as many doillars out of their customers as the possibly can. I won’t be purchasing any of their products again. Here’s what they said in a recent email…

In response to customer feedback, we have decided to return to private, one-on-one technical support via a new and improved ticket system. Technical support for installation and activation of our products will continue to be provided at no cost. All other technical support tickets will cost $49.99 – or you can opt to schedule a Premier phone appointment with a Technical Support expert for $99.99. We are confident that this change will allow us to continue to reduce our response time and maintain the high level of quality of support provided to you.

Any open threads currently in the forums will be resolved at no cost.  We will also leave the forums accessible for reference and there is a new feature in the support section that will allow you to search for answers across all of our support pages, tutorials, and online documentation.

So, what they are basically saying is ‘in future, rather than offering free support and sharing the solutions with the thousands of people who use this forum, we will now be charging you $50 and anyone else who needs the same solution will also have to pay $50.

Great way to raise more money and alienate your userbase, WebAssist. I’ve lost count of the number of times I’ve used the forums to find an answer to a tricky database or CSS question and now you are saying that if I want an answer to anything that isn’t covered in your documentation I have to pay?

I don’t think so!

It wouldn’t be so bad if WebAssist had simply said – ‘sorry guys, we don’t want our staff wasting their time answering questions in our support forum so we’re going to have to charge you for that, but you are welcome to continue using the forums for peer to peer support’. But no, instead what they have done is change the forums to ‘read only’ so no threads can be answered and no new posts can be submitted.

I guess there are going to be a lot more WebAssist questions asked over at Sitepoint.com in the future, where the experts don’t charge for an answer.

The mind boggles at how some ‘bright spark’ at WebAssist came up with this so called improvement. He or she is almost certainly not a developer themselves.

Technology – Which Way Is It Moving Us?

There’s no doubt that technology has advanced at an extraordinary rate over the past 20 years, but you really have to wonder if it is stunting our growth in some areas and causing us additional stress that just didn’t exist before the technological boom.

One of the most obvious side effects of technology is the increased desire for everything to be instant. You can buy just about anything online and some products such as music and video are delivered instantly. We can pay our bills, transfer money and book tickets to a theatre production all with a few mouse clicks.

Our expectations for support, particularly technical support, are much higher than they used to be. If the person providing a service is online then we expect them to be available 24/7/365. As a programmer I know that many of my customers expect to be able to contact me any evening, public holiday or weekend and there’s no such thing as penalty rates for online service providers, programmers or web developers.

Our kids spend more time online than they do with their ‘offline’ friends. I remember when I was young I used to walk to my friends houses to see if they wanted to hang around, play some cricket or baseball or watch some TV. Nowadays just about everyone is just an SMS away. It would be interesting to compare the average distance a child would walk each week thirty years ago compared to today. It’s no wonder that obesity has become such a major problem for some kids.

Of course there is also the other side of technology. With the information that is available on the Internet, most of us can access more information in a couple of days than most people would have had available in a lifetime 40 or 50 years ago. For businesses it is much cheaper to use email or SMS than it ever was to use the landline – particularly for interstate and international calls.

It’s definitely food for thought though – the cost savings and efficiency improvements verses the stress, health and anti social aspects of technology.

My Little Experiment

So, here’s the deal. My ambitions include public speaking (about personal development) and making a living just by being one of the online ‘good guys’. I’m not talking about the good guys that give with one hand and take with the other – I’m talking about building something here that is really useful to a lot of people.

I’m 47 and I have a mess of life experiences and a whole lot of technical and programming ‘head stuff’ to share. Up until now I’ve been putting blogs up with the primary intention of making money from them. Big mistake. I’m not saying that it isn’t possible to make money from ‘niche’ blogs – what I am saying is that it just isn’t ‘me’. I enjoy doing things that have a lot more purpose than just making money.

Crikey – what legacy would you rather leave? Would you want people saying ‘oh yeah, he made a s@*t load of money’ or ‘he really made a difference – we’re going to miss him’. I know what I’d rather and as the years go by and the clock keeps ticking I figure I better hurry up and do something useful!

So… I’m going to experiment on this blog with the Thesis theme. It seems that it has way more options than anything else out there, but there’s a learning curve. Specifically you need to be fairly good with CSS. It’s never been a strong point, though I’ve been using CSS quite a bit over the past year, so I guess now is as good a time as any to start learning.

So if you happen to drop by and the whole blog is upside down… fear not! It’s just me ‘sperimentin’ :)

Internet Filtering In Australia – A Necessary Evil?

I’ll be honest – I have been totally opposed to any form of Internet filtering. When Stephen Conroy announced new plans to filter the Internet in Australia I immediately thought that perhaps he was following in the foot steps of our best known luddite – Richard Alston. Alston came up with some of the most hilarious ideas and suggestions during his term as minister for communications, including his statement that the only thing the Internet was used for was porn.

Anyway – getting back to Conroy…. we all know that it just isn’t possible to ‘filter’ the internet. There are always proxies and other ways of getting around access restrictions. You have to ask yourself though – what is the filtering really about? If it is about preventing adults from deciding what is good for them and what is not then I can see the anti-censorship argument. On the other hand, if it is about removing the potential ‘customers’ of people who provide illegal material then is that such a bad thing?

There’s no question that it’s incredibly controversial but if you are opposed to this filtering policy then first ask yourself… why?

Are you a pedophile who is going to lose access to the abhorrent sites that peddle child pornography?

Do you believe all the trumped up suggestions that it’s ‘going to slow the whole internet down’? Don’t forget that our NBN will increase speed by around 100 times, so any slight delay caused by a content filter will make no difference. The delays or ‘slowness’ they talk about are in terms of milliseconds so don’t be fooled that it’s something you will actually notice.

Are you a ‘free speech’ supporter who believes that any censorship is a bad thing. If that’s the case, does that mean that you support the supply and distribution of child pornography and other obscene content? You can’t have it both ways!

At the end of the day, I think the success or failure of filtering will rest on how smart the government is when they implement it. if they have an adequately staffed department that is able to react swiftly to reports of false positives and other mistakenly filtered material then I’m sure the majority of the public will accept that it is a necessary evil. I guess we will just have to wait and see…

Write It Down!

Having used (and sometimes abused!) computers for the past thirty years or so, I’ve often tried to stay, for the most part, paperless. I’ve recently come to the conclusion that it’s not necessarily the best way to go. For sure it’s great to save a few trees, but there are some times when it just feels ‘right’ to have some things on paper. Since I’ve been listening to Jim Rohn and other success gurus talking about the value of writing down thoughts and ideas I’ve started keeping a journal. I’ve lost count of the number of times I’ve heard really useful little snippets of info and then completely lost them because I either didn’t write them down or I entered them into whatever organizer program happened to be my flavour of the month (I have a bad habit of switching software regularly).

Here’s an example… I was listening to an intro to Matt Bacak’s Secret Money Ring system this evening and there were three things that he said that I thought warranted writing down for future reference.

1. They can take anything away from you, but they can’t take what you know.

This really struck a chord as my whole life these days revolves around studying and learning. To quote Jim Rohn – “Learning is the beginning of wealth”. It really is the most valuable possession that we all have – what we’ve learned. It would be easy to write an entire book on just how essential learning is to success. Not just financial success but also success in our own lives, success in our health, success with family relationships and success with business relationships.

2. Start by making your first dollar – then it’s real.

Matt was talking about goals, and specifically how his first goal was to make a single dollar online. When you make that dollar, online marketing becomes real. Then you work on your first $100, your first $1,000, your first $10,000, your first $100,000 and of course – your first $1,000,000. Goal setting is one another essential component of being successful.

3. There are talkers, thinkers and walkers.

How true is that? There are people who talk about doing things, people who think about doing things and then that small group of people (the walkers) who actually do it!

So there you have it – 3 little gems of wisdom that I now have in my journal that I can refer back to whenever I like (regardless of what software I am using on my computer)! I’m really looking forward to looking back at those notes in a year or two, to see how much walking I did, what goals I achieved and how much more I know. Perhaps I’ll write a blog post about it :) .

What's More Important – Units Sold Or Lives Changed?

I guess it depends on what business you are in. If you are in the business of making money then units sold has to be the key indicator of success. If you are in the business of creating a unique life for yourself then I think that lives changed would be higher on your list of priorities.

There’s nothing wrong with making money of course – it’s what most economies are based on. When you don’t really care how you make money or at what cost it comes to your customers then ‘units sold’ can turn into greed.

Let’s be realistic though. Not all products or services can change lives… at least not directly. If I buy a packet of kitchen sponges or a box of toothpicks, they aren’t going to turn my life around or bring me great success. But even basic products like sponges and toothpicks have the potential to change lives. It may be that the owners of the sponge and toothpick companies give a percentage of their profits to charities and other worthwhile causes.

Home At Last!

Do you know how hard it is to find a decent domain name with ‘Gary Smith’ in it?  I gave up trying some time ago after I registered garysmith.gs (my old blog). I thought it was pretty cool at the time but I really wanted a dot com. After all, most of the work I do and all of my own servers are based in the U.S.A. So here is my final home. Seriously! This is it!

I think I think way too much so I’ll be talking about all sorts of things here. I’ve been working from home, mainly programming for online marketers, for the past 5 years… so I’ll be talking about some of what I’ve learned over those years.

This year I’ve been studying personal development so I’ll also be offering my words of wisdom and talking about things that have changed my attitude and general outlook on life. I hope you will drop by from time to time and comment on some of the things I’ll be writing about.

On The Road – Alice Springs

My daughter has a friend over from Canada – staying with us for 2 months. We decided last year that when she came to Australia we’d basically trek around with her. So I signed up for some wireless broadband access and we started our adventure at Alice Springs. Given that it was going to take 2-3 days each way to drive there and back we decided to fly which takes around 3 hours.

I’m spending most of my time in the hotels we’re staying at – it’s pretty much a ‘working holiday’ while the girls go and see the sites. I did take one day off though to walk around Uluru (formally known as Ayers Rock). I’d only ever seen it on the television and in magazines so it was a real buzz to view the real thing. It’s every bit as spectacular as I expected it would be. The tour we went on was ‘Uluru/Kata Tjuta and Back In a Day‘ with Emu Run Tours and it was a great day all around. The guides were knowledgable, funny and helpful throughout the day which ended with a barbeque and champagne at the Uluru sunset viewing area. If you are planning on visiting Alice Springs and the surrounding area I can definitely recommend Emu Run Tours.

We stayed at a motel for 4 nights – the Swagmans Rest Motel. It was neat and clean and very comfortable. It’s also close enough to the CBD that you can walk there in around 15 minutes. We ate out one night at The Juicy Rump – which is a restaurant at Lasseters Casino. The steak was excellent and it’s a very popular eatery with a lot of atmosphere.