Web development

Dragging and dropping table rows in Javascript

Sunday, July 1st, 2007 by DenisH

Summary: This article tells you how to implement drag and drop for HTML tables in Javascript. You can download the source here and play with the demo here.

Updated: now copes with multiple tables on the same page, non-drag and non-drop rows (such as headers) and embedding form elements. (more…)

Confirming a URL in Javascript

Tuesday, June 26th, 2007 by DenisH

This is a little tip that I discovered a while ago but which I’m always forgetting, so I thought I’d post it here where I woudn’t lose it! Sometimes you’ll have a link on a web page which actually does something to a database, deletes the current thing for example. In those circumstances you want to have some sort of “Are you sure?” confirmation.

Javascript has a confirm dialog that you can use, but because you can use the return value of a method to determine event bubbling, you can use this really neatly to give optional links as follows:


onclick=”javascript:return confirm(’Are you sure you want to go to our home page ?’)”
>Click here to go to home page

And of course you can try it yourself: Click here to go to home page.

If you click OK, then the confirm returns true and the link is followed. If you click Cancel, then confirm returns false and the event isn’t bubbled up to the href handler and so the link isn’t followed and you stay on the same page.

Javascript debugging, Firefox and Drag and Drop

Thursday, May 17th, 2007 by DenisH

In one of my current projects I need to have a table of data that the user can reorder. A quick search of the internet doesn’t turn up any javascript howtos or frameworks that allow dragging and dropping of table rows, so I had to role my own. I’ve written an article about how to do it, here. (more…)

Firefox development toolbar

Wednesday, October 4th, 2006 by DenisH

A friend recently pointed me to a useful development toolbar for Firefox. It’s similar to the development toolbar here but does even more stuff.

You can find the toolbar at http://chrispederick.com/work/webdeveloper/.

Definitely worth having if you’re working with Firefox (in fact I often use Firefox for debugging Javascript and the like because it tends to be much more helpful than IE!).

xml:space="preserve" and xsl:attribute

Wednesday, September 27th, 2006 by DenisH

Just a quick tip about xsl which I haven’t found anywhere else…

I wanted to generate some human (well me) readable XML using XSL and found that if you add xml:space=”preserve” to the opening tag, then, at least if you are using Xalan and Java to do the transformation, it will preserve the spaces between the tags in the XSL and you’ll get something more or less readable. (more…)