Skip to main content

Create Multiple Instances

You can create multiple, independent Postcode Lookup fields on the same page. This is useful for certain requirements, e.g. separate billing and shipping addresses.

setup can be invoked multiple times on different DOM elements to create multiple fields.

Each lookup field is independent and so can behave differently if you pass in different configuration settings.

 
// Initialize each lookup field individually. You can specify completely different configurations. Each is isolated from the other.
// Hook up the first lookup field
PostcodeLookup.setup({
apiKey: "ak_test",
context: "#lookup_field",
outputFields: {
line_1: "#first_line",
line_2: "#second_line",
line_3: "#third_line",
post_town: "#post_town",
postcode: "#postcode"
}
});
// Hookup the second lookup field
PostcodeLookup.setup({
apiKey: "ak_test",
context: "#lookup_field_2",
outputFields: {
line_1: "#first_line_2",
line_2: "#second_line_2",
line_3: "#third_line_2",
post_town: "#post_town_2",
postcode: "#postcode_2"
}
});

Live Demo

Loading...