Respond to address selected JavaScript event with PostcodeAnywhere Capture+

Capture+ allows you to pop some code in your page and configure a JavaScript-driven address finder through your browser.

We wanted to hide the address fields until you select the address from the postcode lookup.

It doesn’t appear to let you customise the JavaScript in any way to allow this, however a query to their support turned up that you can respond to the event when a user selects an address with the following JavaScript:

<script type="text/javascript">
    capturePlus.listen("load", function(control) {
        //custom code
        control.listen("populate", function(address) {
            console.log("User selected: " + address.PostalCode);
			        });
    });
</script>

As this isn’t documented anywhere on their site I thought I would post it in case anyone else needs to know how to do this!

UPDATE: Actually it is documented at the end of http://www.postcodeanywhere.co.uk/support/articles/article/getting-started-with-captureplus

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.