Patterns for multiple forms



I’m currently sat at home ill and am thinking about a problem I’ve
been looking at recently.

I have a form that lets users enter orders into a system. At the
moment its all pretty simple stuff (proof of concept rather than
working just for the time being), with basic details about an order
and a place for them to enter billing and delivery addresses.

I am also integrating the address entry with an external web-service
allowing users to enter their postal codes and have their full
addresses entered for them. I’m trying to find a way for this to be
handled in an AJAX fashion, so that they can have their addresses
completed without needing popups or anything else.

The problem I have is this:

I need an outer form that handles the regular order submission – the
kind that Rails’ scaffold would generate for you, and then some sub-
form type behaviour for the address lookups, enabling users to click
buttons after entering a postcode, have a drop-down list appear, and
then click another button to have the details then transferred to the
outer form’s address fields.

I have it kind of working, but, crucially not the form-within-form
scenario, it looks like I’ll need to have just one form and then
detect what button was clicked – kind of the way that ASP.NET’s
postback model works. I’m just wondering whether others have
approached similar things, and if they have any suggestions for the
best way to handle this kind of thing.