4 entries in jQuery

jQuery Favelet

Add jQuery functionality to any browsable web page

Saturday, February 23rd, 2008

Any developer worth his salt knows about Firebug and its JavaScript console. I use it all the time to tinker with web pages, test stuff out and debug my own pages.

But sometimes, if I'm *cough* hacking *cough cough* someone else's page, I need the added power of jQuery! But what if the page doesn't have it?

Simple - load jQuery from a remote source manually through a javascript: call.

Save Favelet

Just drag the link below to your Links toolbar, then click it on any page to jQuery-enable it.

Add jQuery to page

Test it out!

Save the Favelet and click on it (or just click the link above), then: animate page.

Simple!

jQuery “Highlight” plugin

Highlight a form field’s parent tag (or any other selector) as you tab into it.

Tuesday, February 12th, 2008

Highlight increases usability by highlighting elements as you interact with the page.

Its primary use is for forms, but it can also be used for tables, lists, or any element you specify. It can also be used to toggle elements on and off, for example, table rows.

Examples uses:

  • Form-filling can be made clearer by highlighting the element around a control as you tab into it
  • Table rows can be made more visible as you pass the mouse over them, or click them
  • Elements can be toggled as you click them

Code example

Because of the defaults, basic usage can be as simple as:

$('form').highlight()

The method signature for Highlight is:

$(selector).highlight(parentSelector, highlightClass, startEvent, endEvent)

Demo

View the Highlight demo which has examples for forms, tables, and lists.

Download

jQuery “Populate” plugin

Populate a form or an element's child elements using a JSON object.

Tuesday, February 12th, 2008

I don't like mixing HTML and PHP when I build my forms. Instead I like to keep my HTML completely clean, then if a form needs to be pre-filled (for example retrieving a bunch of database results), get JavaScript to fill it in for me after the page has loaded.

This plugin supports full PHP naming and deep data structures, as well as checkbox arrays and other non-standard UI controls. The plugin can be used as part of your AJAX toolkit, or for separating server-side code from HTML by populating a form after the page has loaded eg:

$('form').populate({text:'text', radio:1})

and not inline as the page is processed, such as:

<input type="text" name="text" id="text" value="<?php echo $text; ?>" />
<input type="radio" name="radio" id="radio-1" checked="<?php echo $val == 1; ?>" />
<input type="radio" name="radio" id="radio-2" checked="<?php echo $val == 2; ?>" />

You can also populate non-form controls such as <div>s, by specifiying the id and an identifying attribute (defaults to id):

$('div').populate({'text-1':'text', 'text-2':'More text'})

This can be useful when you want to show the results of a database call, but don't want the text to be editable.

Instructions and demos

I've now FINALLY put up a full set of instructions and a working demo, with examples of:

  • Populating a simple form, using string variable types for textfields, radiobuttons, dropdowns and checkboxes
  • Populating a complex form, using array variable types for checkbox arrays and multi-list boxes
  • Populating a hierarchical form, using hierarchical JSON data

View the jQuery Populate Demo here.

Download

JavaScript

PHP

Form builder

Convert a list of text into fully validated, accessible HTML form controls

Monday, February 11th, 2008

I've got really, really tired of re-inventing the wheel (alright, HTML, CSS, JavaScript) every time when it comes to site forms.

I do so much database stuff these days that seems to be virtually every site I'm starting from scratch, or hacking an old site's template to work on a new site. Then once the CSS has been hammered out, comes the laborious task of form validation - tidying up all the names and ids, dusting off my RegExp-foo to validate emails, usernames, etc, etc.

It's very time-consuming and just feels like I'm missing a trick!

Wouldn't it be great if there was a magic bullet to convert a list of text into fully validated, accessible HTML form controls!?

Form Builder

Enter "Form Builder" - an online JavaScript application that will build accessible, cross-platform and validated form HTML in literally 10 seconds flat. Just type or paste in your form labels, edit some options (if you want to) and view the Live Preview and HTML.

Form builder does pretty much everything you might want...

So I've done some hard research and have employed best-practices for:

  • HTML Code
  • Styling
  • Accessibility
  • Validation

For example, what about:

  • Ease of use: copy all your labels to one text field and a whole set of controls built on linebreaks, tabs, commas
  • Live preview: not happy with the code? Edit the HTML and watch the Live Preview update
  • Intelligent attribute naming: for example, a form label is "Blood pressure (mmHg)", your names and ids are truncated at the first illegal character and re-named "blood_pressure" / "blood-pressure"
  • Automatic values: values are automatically built from the label names, or you can just paste in another list of values
  • PHP (or other) naming styles: specify a data sub-group, or use your own square bracket naming [] to group data into discrete chunks
  • Accessible HTML: all controls are married with labels, and where appropriate wrapped within <fieldset> tags
  • Validation: Optionally include basic validation attributes on elements using jQuery's Validation plugin.

Jump in and play here, then go do something more useful with all that spare time!