Christian Heilmann

Posts Tagged ‘forms’

Adding address information automatically to forms with GeoFill

Sunday, June 7th, 2009

One of the things I mentioned in my latest talk and the follow-up Q&A at Gumtree was that I am very interested in Geolocation and automatically detecting the user’s location to save them having to enter all the same info over and over again. Sure, location services like Fire Eagle and autofill options in browsers already do these kind of things, but they are power user toys for now.

Using Rasmus Lerdorf’s GeoIP, YQL and Yahoo Geo I’ve put together a small JavaScript wrapper that does exactly this for you:

GeoFill - automatically filling form data with geo information by  you.

GeoFill (also available on GitHub) allows you to use two different methods to automatically fill forms with geo information:

  • geofill.find(properties) does an IP lookup of the current user and tries to get the geographical data from that one.
  • geofill.lookup(properties,postcode) tries to get the geographical data from the postcode provided in your form.

Both methods take an object which lists the form field IDs to be filled as the parameter. The data returned is city, country, postcode, latitude and longitude.

Both methods also allow you to define a callback function to handle errors or re-use the data in other ways than filling form fields.

For example to get the information connected with a post code you could simply do the following:




The returned object is:

country:”United Kingdom”,
postcode:”WC2H 8AD”

Useful? In any case it made me play more with the Geo API. Don’t forget that on the 7th of July I’ll be giving a free Tech Talk on Yahoo Placemaker where this will be one of the demos (probably, knowing myself I’ll have hacked other stuff by then). You can sign up for the tech talk on upcoming.

Using Twitter as a data provider to automatically fill forms

Thursday, January 8th, 2009

I hate having to enter all my details when I fill forms – especially when I know for a fact that I’ve entered them before. Looking at Smashing Magazine’s Twitter Avatar WordPress Plugin I got to play with the show API of twitter, which gives you user information.

For example to get my information in Twitter you can just call and get all I entered. This is also available in JSON and with a callback parameter. You can also do a lookup by email, by calling Using both of these together, I thought it’d be a good idea to use this API to automatically fill forms.

I’ve created a quick proof of concept: automatically filling forms with twitter data . If you want to use the script yourself (twitterfill.js), simply add it to the page with your form and give it the right parameters in the init method. For the demo page this is:

The parameters are label, which is the text of the button, loading, which is the loading message, mailfield, which is the ID of the email field (the button will be inserted after it), and name,location and url which are the IDs of the form fields you want to fill.