<link rel="stylesheet" href="https://cloud.hopewiser.com/jsclient2/hpw-intl-jsclient2.css" />
Before the </body> closing tag of your web page, add these lines…
<script src="https://cloud.hopewiser.com/jsclient2/jquery.min.js"></script>
<script src="https://cloud.hopewiser.com/jsclient2/bootstrap.min.js"></script>
<script src="https://cloud.hopewiser.com/jsclient2/json2.min.js"></script>
<script src="https://cloud.hopewiser.com/jsclient2/hpw-intl-jsclient2.min.js"></script>
Replace ‘https://cloud.hopewiser.com/jsclient2’ with the relative path of the folder if you chose to install these files on your own web server in place of using the Hopewiser hosted resources. Details of how to obtain local International JavaScript components required can be located in the Customisation section “How do I install International JavaScript Client service files locally?”
If your web site is already using jQuery, Bootstrap or json2, you may be able to omit the applicable lines or reference your existing installation as necessary.
Add a button with the following attributes to your web page:
<button type="button" data-toggle="modal" data-target="#hpwModal" data-backdrop="static" onclick="btnFindAddress_onclick()">Find Address</button>
The HPWINTL_JavaScript and btnFindAddress_onclick functions need to be declared in the <head> of the web page. The first function contains a configurable HPWINTL object, whilst the second function handles the FindAddress’s onclick event. The onclick event is where the HPWINTL_JavaScript(HPWINTL.ADDRESS_SEARCH() function will be triggered:
<script>
HPWINTL_JavaScript(mode) {
HPWINTL.FindAddress({ ...});
}
function btnFindAddress_onclick() {
HPWINTL_JavaScript(HPWINTL.ADDRESS_SEARCH);
}
</script>
One of the following three methods must be called to specify the country code values that are defined in the country drop-down box (please refer to the Customisations section called How do I populate the list of countries for details and distinctions of each)…
HPWINTL_JavaScript(HPWINTL.USE_OWN_CODES);
HPWINTL_JavaScript(HPWINTL.USE_ALPHA2_CODES);
HPWINTL_JavaScript(HPWINTL.USE_ALPHA3_CODES);
The HPWINTL.FindAddress() function takes a JavaScript object containing:
- Your authorisation code
- The HTML ID of your input field
- The HTML ID of your country drop-down field
- An optional CSV string containing a list of ISO 3166 alpha-3 codes to list your preferred countries (if using HPWINTL.USE_OWN_CODES)
- An object containing the HTML IDs of your output fields
- A system Mode parameter
If your web page has separate address fields
Specify their HTML IDs in the output object, e.g.
function HPWINTL_JavaScript(mode) {
HPWINTL.FindAddress({
auth: "yourAuthCode", // required
input: "txtInput", // required
countryListBox: 'inpCountryList', // required
output: {
line1: "txtLine1", // required
line2: "txtLine2", // optional
line3: "txtLine3", // optional
line4: "txtTown", // optional
line5: "txtCounty", // optional
line6: "txtPostcode" // optional
},
Mode: mode
});
}
If your web page has a single multi-line address field
Specify its HTML ID against each address line you want to be returned, e.g.
function HPWINTL_JavaScript(mode) {
HPWINTL.FindAddress({
auth: "yourAuthCode", // required
input: "txtInput", // required
countryListBox: 'inpCountryList', // required
output: {
line1: "txtAddress", // required
line2: "txtAddress", // optional
line3: "txtAddress", // optional
line4: "txtAddress", // optional
line5: "txtAddress", // optional
line6: "txtAddress", // optional
line7: "txtAddress" // optional
},
Mode: mode
});
}
</script>
Replace yourAuthCode with your authorisation code and the example HTML IDs with your actual HTML IDs.) The address label is not formatted. For a matched address, this will contain one or more address lines which will be written to line1-7 in that order for each of the output field mappings that are provided. The input field does not have to be a separate field; it can be one of the output fields.