Wednesday, 7 November 2007

stop event bubbling in js and prototype.js

Prototype.js has the stop() function, which also stops the default behaviour of an action. sometimes you want to just stop the bubble rather than the default action (for example on checkboxes)

so cross browser function to do it:

function cancel_bubble_event(event) {
//cancel the bubble but not the default action
if (event.stopPropagation){
event.stopPropagation();
}else{
event.cancelBubble = true;
}
}

called by:

window.cancel_bubble_event(event);

Wednesday, 24 October 2007

Update multiple rows from a query

use the following SQL as an example:

UPDATE the_table
SET a_column=a.other_column
FROM (
select other_id,other_column from other_table
)as a

WHERE
the_table.id = a.other_id

Tuesday, 7 August 2007

Create PDF forms and documents for free

Use Openoffice (http://download.openoffice.org/2.2.1/index.html) to create a document, adding any form fields you need then export as PDF.

Note: form fields in PDF forms shouldn't contain any underscore (_) characters, or else the values aren't sent to the processing webserver. Or at least that is the case with PDF forms created via Openoffice - so avoid anything other than normal letters and numbers in form field names

Table of contents can be created on OpenOffice, as well as specifying the default opening mode of PDF files.

Multiple images as multipage pdf

Install PDFcreator (http://www.pdfforge.org/products/pdfcreator/download) then open the image in the windows picture and fax viewer - usually the default viewer when you double click it.

If all the images are in the same folder you'll be able to select them all on the printing wizard, then choose PDFcreator as the printer and save the output - Multiple images as multipage pdf.

Edit setup image with Orca.exe


To edit the setup image of an .msi in ORCA.exe use the binary table then edit the DefBannerBitmap key, by double clicking on it. This will show the 'Edit binary stream' screen. Navigate to the .bmp file you saved earlier and click 'OK' to update it, then save the new MSI file. You can also write the original to file here to, in order to edit it in PS or where-ever.

Note the .bmp must be a 500px (wide) by 70px (heigh) image, saved as index colour (8 bit) bmp file.