Rosher Consulting

Software Consulting and Development Services

jQuery : working with SELECT lists

I’ve recently had to do some work with SELECT lists using jQuery and found the documentation to be a little sparse, there’s a few good articles out there, such as this one, but I couldn’t find any that had everything I needed so I thought I would share my experiences and provide a few examples to help others, so here goes.

(Disclaimer: I’m not suggesting that any of these snippets are necessarily the best or the fastest way to do things but they get the job done, your mileage may vary!)

To handle changes and get the currently selected value:

$("#mySelect").change(function (event) {

Retrieving the text of the currently selected option:

$("#mySelect option:selected").text();

With the above you could also remove the option and just do:

$("#mySelect :selected").text();

however I’ve always thought that jQuery selectors should be as specific as possible for performance reasons, hence why I use the former, though I doubt in this case that it would make any difference.

Finding an option by its value:

var listitem = $("#mySelect option[value=" + valueToFind + "]");

Finding an option by its text value:

// The following should work but doesn't in all browsers:
var listitem = $("select option[text='" + textToFind + "']");
// Since the above doesn't work in all browsers we can manually search 
// through all list items on the page
var listitem = null;
$("select option").each(function() {
    if ($(this).text() === textToFind) {
        listitem = $(this);

Retrieving all options:

var options = $("#mySelect option");

Removing all options:

$("#mySelect option").remove();

Removing the currently selected option:

$("#mySelect option:selected").remove();

Adding an option:

$("#mySelect").append("<option value=\"" + myValue + "\">" + myText + "</option>");

How many options are there:

var count = $("#mySelect option").length;

Hiding all selects on the page:

var selects = $("select:visible");

You may wonder why I assigned a variable before hiding the selects, well you’ll also notice that I only selected visible elements because if you’re hiding them to show an overlay (which you would need to do in IE6) then you’ll only want to show the selects that were visible before you showed your overlay, hence why they’re stored in a variable.

That should cover most of what you’ll need to do with SELECTS, if you spot any mistakes or anything that could be improved then let me know in the comments.

Asus TA-D31 Case

I’ve just been putting together a Windows Home Server machine and needed to order a new case, I came across the Asus TA-D31, but apart from the stock image I couldn’t find any others of this case, so I thought I’d post some in case anyone else was looking.

The case isn’t the best in the world but for £26 you can’t argue with its value, it’s got a decent amount of drive bays and plenty of space to work in and since it’s going to be out of sight and out of mind it doesn’t really matter what it looks like.

IMG_5048 IMG_5049 IMG_5050 IMG_5051 IMG_5052 IMG_5054 IMG_5053

Creating drive image backups with DriveImage XML on Windows 7

I’ve been installing the release candidate of Windows 7 on most of my machines of late and since I didn’t want to dual boot the systems or lose the existing install of Windows XP I decided I’d try out some drive imaging software to backup the existing data on the drives.

I came across DriveImage XMLl which is a great little app for backing up your drives and would you believe it’s also free for personal use, can’t argue with that. Over the past few weeks this app has really saved me countless hours of re-installs as I troubleshooted problems with Win7 and then fresh installs of WinXP on the new server I was building. However I initially had some problems creating a successful backup on Win7 so I thought it would be useful if I document it for others and just generally gave an overview of DriveImage XML.

DriveImage XML uses either volume locking or volume shadow services to create a hot image of your drive while Windows is running, by default it tries to use volume locking first and if that doesn’t work it will try volume shadow services. In WinXP this all works fine, but in Windows 7 it firstly fails to lock the drive and the volume shadow service isn’t running so it can’t use that either. It will warn you and you can attempt to carry on, which is what I initially did and I managed to create a successful backup, but there’s a better way!

First we need to make sure that the ‘Volume Shadow Copy’ service is running, so open up the services control panel applet (start –> services) and scroll down to find the ‘Volume Shadow Copy’ service. As you can see from the screenshot it’s set to manual, so let’s start it up.

CropperCapture[1]I’m assuming that you’ve already downloaded and installed DriveImage XML, so either find it in the start menu or find the executable in explorer, either way we need to click on the app and choose ‘Run as administrator’ from the popup menu, this makes sure that it will be able to access all of our files.

CropperCapture[3]When DriveImage XMLl starts you’ll be presented with the following screen:

CropperCapture[2]Since we want to perform a backup, click the backup option.

DriveImage XML will then show you the hard drives installed in your system, select the OS drive and click next.

CropperCapture[4]Now choose where you want to create the backup image, ideally this should be on another drive and also you’ll need to make sure that there’s enough free space, then give the image a name, as you can see from the following screenshot I’ve named the backup Win7.

For the ‘Hot Imaging Strategy’ make sure you choose ‘Try Volume Shadow Services first’, I also uncheck the ‘Split large files’ option so that I end up with one large backup file rather than lots of small ones. Click next to continue.

CropperCapture[5]DriveImage XML will now start doing it’s thing, depending on how much data you have on your drive it shouldn’t take that long to create the backup, mine only took 5 minutes for an 8gig backup.



When it’s finished you should find you have a large ‘dat’ file and an ‘xml’ file:

CropperCapture[11]And that’s all there is to it, of course at some point you’re going to need to check that your backups actually work, for this I’d suggest using a spare drive if you have one and restoring the image there rather than testing it on your main system drive.

One thing I came across when doing the restore’s is that DriveImage XML expects you to restore to an equivalent or larger size disk to the one you created the backup from, which when the backup is only 8gig seems a bit strange. Anyway, I found a way around the problem by editing the XML file to say that the logical drive was actually smaller than it was, just edit the total space value to be equivalent to or smaller than the drive you are restoring to and also remember to adjust the free space value, after that all should be ok and I was able to restore an image from a 160gig drive to an 80gig drive without any problems at all.


Having now used a drive image backup application I can’t believe I’ve lasted so long without it and especially just how much time it’s saved me. It means you’re free to install drivers, apps and anything else without having to worry about whether it will screw up your system because if it does you just revert to the last image you took. Some people may be thinking isn’t that what System Restore does, but anyone who’s ever used system restore will tell you that it never seems to fully clean everything out and your system isn’t quite as it was before.

On a final note, if you want to run DriveImage XML from a BartPE bootdisc, there’s a Portable Edition download on the website and this is how I’ve been using it over the last couple of weeks.

PSP Go disappoints (to me anyway…)

pspgo When the PSP was announced 4 years ago I couldn’t wait to get my hands on one and when I did pick one up I was really impressed with it. It was far from perfect, but it had a fairly decent selection of games and a reasonable control scheme for a handheld.

Fast forward 4 years and rumours of a PSP 2 have been around for ages with many people including myself hoping that they would fix the deficiencies in the first gen device, in particular I was hoping they’d:

  • Sort out the D-pad: for a lot of games it works fine, but for things like Streetfighter it’s awful, you need a D-pad that can easily be rocked into the corner quadrants.
  • 2nd analogue stick: FPS games that have come out for the PSP have made the most of the controls, but a 2nd analogue stick would be killer.
  • Ditch the UMD format: OK, they got this one right, UMD’s were/are a pain in the backside, I used to rip my games and play them from the memory stick.
  • Ditch the memory stick format: I’m sure I read recently that Sony are starting to use MicroSD cards, why they can’t do this on the PSP baffles me.
  • Price: £214 seriously! If you want to compete with the DS you’ve got to have a lower price point, no matter how good the device is, parents will always look at the lower priced option.
  • Games: the last time I purchased a game for my PSP was probably 18 months or more ago, there’s just not enough quality or original games coming out for the platform. Name me the truly original, first class games for the PSP… I can only think of a handful, the rest are all ports of PS2 games.

I like the idea of the digital distribution of content, I think the iPhone app store has shown everyone how effective it can be, my only concern is Sony’s track record with their dodgy software.

Overall I don’t think I’ll be purchasing a PSP Go, my current PSP sits in the cupboard and doesn’t get much use as it is and the new device just doesn’t offer me the features I was looking for.

When you think about it, all Sony have really given us is a slimmed down version of the PSP and one that can’t even play the existing UMD games!