Web Developer
Archive for June, 2008
jQuery Table sorter
Jun 18th
While making a e commerce application I wanted the ability to easily sort product and categories by click and drag. Basically to allow the customer to re-order the way their products and categories are displayed. No doubt that you’ve seen application that have numerous “move up” and “move down” buttons that seem to take forever to use and from development point of view cumbersome to do. Of course the other method is to have input boxes with numbers in that can be altered, again cumbersome for both user and designer.
Being a massive fan of jQuery I thought there must a easy ‘drag and drop’ solution. I regular use the interface plugins that covers most of my needs. Though they provide a ‘sortable’ plugin that works great for divs, it simply cannot sort tables due to the fact that certain CSS styles (like position static) cannot be applied to table rows.
After a long search I eventually came across a plugin solution called ‘Table Drag and Drop’. This simple plugin like all jQuery requires just a small amount of code to get it working.
$(document).ready(function() { $("#mytable").tableDnD(); });
To apply to a basic table like this:
<table id="mytable" border="1"> <tbody> <tr id="product_1"> <td>My Product 1</td> <td>£10.00</td> <td>Active</td> </tr> <tr id="product_2"> <td>My Product 2</td> <td>£2.99</td> <td>Not active</td> </tr> <tr id="product_3"> <td>My Product 3</td> <td>£23.49</td> <td>Not active</td> </tr> <tr id="product_4"> <td>My Product 4</td> <td>£19.99</td> <td>Active</td> </tr> <tr id="product_5"> <td>My Product 5</td> <td>£7.99</td> <td>Not active</td> </tr> </tbody></table>
This will give you the following results like this (try dragging the rows):
| My Product 1 | £10.00 | Active |
| My Product 2 | £2.99 | Not active |
| My Product 3 | £23.49 | Not active |
| My Product 4 | £19.99 | Active |
| My Product 5 | £7.99 | Not active |
I’ve had success with this with the most complicated tables with embeded forms, complex CSS styling and 100+ rows without problems. The plugin includes various settings to assign different classes when dragging to get a user friendly feel.
Now you probably wondering how you can now get this ordering information back to the web sever to save it in the database. Database storage is simple, use a attribute storing a int and simply update the table in the order which they are received. It has a call back function called serialize(). This is an array with containing the id’s of the table rows in the new order in the table. Just loop these values update the table.
This code uses simple table with some CSS styling and POST an array back to a web sever with the new order.
$(document).ready(function() { $('#mytable2').tableDnD({ onDragClass: "dragrow", onDrop: function(table, row) { // get the serialized data for transport serial = $.tableDnD.serialize(); // use jQuery ajax function to send information $.ajax({ type: "POST", url: "inc/product_controller_ajax.php", data: serial, }); } }); });
#mytable2 { border: 2px solid black; border-collapse: collapse; width: 50%; } .row1 { background-color: #d8dff4; } .row2 { background-color: #f7e8e9; } .dragrow { background-color: #a70707; color: #ffffff; }
| My Product 1 | £10.00 | Active |
| My Product 2 | £2.99 | Not active |
| My Product 3 | £23.49 | Not active |
| My Product 4 | £19.99 | Active |
| My Product 5 | £7.99 | Not active |
Now at the sever side all you have to do is loop through the value sent via ajax. I have used POST in this example. The name of the value is the ID of the table, so for example a PHP solution for this is as follows:
1 2 3 4 5 | <?php foreach($_POST['mytable2'] as $line){ echo $line; // product_2, product_2... etc in new order } ?> |
Links
Firefox 3 – The best bits
Jun 14th
The latest version of Mozilla Firefox is due to be released later early next week on the 17th June 2008. I’ve been participating in the pre-release testing and cant say enough good points about it. If it wasn’t for incompatibility for certain addons I use (namely firebug) I would of switched to it weeks ago. Now RC3 has been released compatibility for popular addons such as foxmarks and firebug are now available.
So why should I bother downloading (7 Mb) and installing FF3?
As you’ve all probably already read on the web site FF3 has major security, performance, improved password management, anti virus integration & a download manager just to name a few.
What interest me is features that ultimately change the way we surf the web and interact with our web browser. FF3 takes two classic old web browsing features; bookmarks (favourites) and history and gives them a new lease of life. If you like me i’ve really used the history because its always been pretty inaccessible to search. I use bookmarks but can never find anything in them and normally just re-search it on Google.
FF3 provides loads of new tools and features to sort, search and tag bookmarks. The best feature is what they call ‘Location bar & auto-complete’. This is a Google suggest inspired search tool that help you to quickly locate that missing bookmark or that pages you know you were once on.
As you can see its clear and indicates if its a current bookmark or not by the star on the right. It has a sort of Facebook search look about it that highlights the matched letter(s) in bold.
There are massive improvements that make upgrading more then worth you while. Firefox RC3.
Changing the spark plugs on a Chrysler Voyager V6
Jun 13th
The rear spark plugs on a Chrysler Voyager V6 (2000) at first seem very difficult to change. I have heard of various methods, from gaining access from underneath the car, to lifting the inlet manifold an inch or two.
I decided to take the easiest approach, which might not be the quickest if you have access to a vehicle lift, but is relatively straight forward.
As well as a new set of spark plugs and ignition leads you may need a new inlet manifold gasket as it could break when you remove the manifold
Below is a step by step photo guide on how to replace the spark plugs, which you might find helpful if tackling the job yourself.
![]() |
|||
| Note position of wiper arms | |||
![]() |
|||
| Remove wiper arm spindle cap | |||
![]() |
|||
| Remove wiper arm spindle nut | |||
![]() |
|||
| Remove wiper arm and wiper top panel screws | |||
![]() |
|||
| Panel clips | |||
![]() |
|||
| Remove flat nuts from wiper top panel studs | |||
![]() |
|||
| Disconnect screen washer tubing | |||
![]() |
|||
| Disconnect screen washer tubing on jets | |||
![]() |
|||
| Remove wiper box top bracket nuts | |||
![]() |
|||
| Remove main wiper box bolts | |||
![]() |
|||
| Remove main wiper box bolts | |||
![]() |
|||
| Remove wiper motor multiplug | |||
![]() |
|||
| Disconnect wiper box drain pipes | |||
![]() |
|||
| Lift out wiper box assembly for easy access to inlet manifold | |||
![]() |
|||
| Remove 3 alternator bracket bolts and rotate plate upwards | |||
![]() |
|||
| Remove distributor bolts | |||
![]() |
|||
| Remove air box and vacuum pipes, breather pipes, multiplugs, throttle cables on throttle body |
|||
![]() |
|||
| Remove exhaust recirculation pipe bolts (a bit tricky) | |||
![]() |
|||
| Remove inlet manifold support bracket bolt from engine block |
|||
![]() |
|||
| Remove cable mounting bracket bolt on back of manifold(left side) (a bit tricky) | |||
![]() |
|||
| Remove cable mounting bracket bolt (right side) (also a bit tricky) |
|||
![]() |
|||
| View of cable bracket/bolts on back of manifold(may assist in removal) | |||
![]() |
|||
| Remove earth wires on bulkhead stud | |||
![]() |
|||
| Remove inlet manifold nuts and bolts | |||
![]() |
|||
| Remove inlet manifold and cover engine inlet ports | |||
![]() |
|||
| Remove ignition leads and Remove and replace rear spark plugs | |||
![]() |
|||
| Remove ignition leads and Remove and replace front spark plugs | |||
![]() |
|||
| Check wiring and multiplug cable mounting bracket | |||
![]() |
|||
| Fit new inlet manifold gasket | |||
![]() |
|||
| Fit new air filter at this stage if necessary and rebuild Refit rear ignition leads; rebuild inlet manifold assembly, electrics and wiper box. |
|||
![]() ![]() ![]() ![]() |
|||
| Parts used | |||



































Recent Comments