I'm attempting to create a postcode lookup JQuery script that'll be able to be used multiple times on a page, without having to duplicate the script for every address on the page. The Find button has the class "postcodeLookup" and the attribute "address" which is how I intended to get the script to populate the right address (it uses JQuery Populate plugin) & the inputs are named address[line1], where "address" is changeable (home[line1], office[line1], etc.).
The problem is how to get the JSON that populates the address to use the variable contents rather than the literal word "address"?
//postcode lookups
$(".postcodeLookup").click(function(){
alert("I am The Postcode Finder...\nPretending to find the address...\nFound it!");
var address = $(this).attr('address');
$("form").populate({
address: {
line1: "First Line of Addr.",
line2: "Line 2!",
line3: "Line 3 of The Address",
postcode: "PO1 1PO"
}
});
$(".addressArea").slideDown('fast');
});