-
Notifications
You must be signed in to change notification settings - Fork 4
/
address-checker-country.html
103 lines (96 loc) · 4.03 KB
/
address-checker-country.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!DOCTYPE html>
<html>
<head>
<title>Address Checker with Country Field | Addy.co.nz</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="UTF-8">
<link type="text/css" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
<!-- only use if loadCss URL query attribute flag is set to false -->
<link type="text/css" rel="stylesheet prefetch" href="./css/addy.min.css">
<!-- or CDN -->
<!-- <link type="text/css" rel="stylesheet prefetch" href="https://www.addysolutions.com/address-lookup/1.6.2/css/addy.min.css"> -->
<style>
body {
font-family: 'Roboto', sans-serif;
font-size: 10pt;
}
.field {
width: 300px;
}
.label {
width: 120px;
}
</style>
</head>
<body>
<form>
<table>
<tr>
<td>Country</td>
<td>
<select id="country" class="field" onchange="onCountryChange(this.value)">
<option value="AUS">Australia</option>
<option value="CAN">Canada</option>
<option value="NZL" selected="">New Zealand</option>
<option value="ZWE">Zimbabwe</option>
</select>
</td>
</tr>
<tr>
<td class="label">Address Line 1</td>
<td><input type="text" class="field" id="address1" placeholder="Start typing an address.." auto-complete></td>
</tr>
<tr>
<td>Address Line 2</td>
<td><input type="text" class="field" id="address2"></td>
</tr>
<tr>
<td>Suburb</td>
<td><input type="text" class="field" id="suburb"></td>
</tr>
<tr>
<td>City/Town</td>
<td><input type="text" class="field" id="city"></td>
</tr>
<tr>
<td>Postcode</td>
<td><input type="text" class="field" id="postcode"></td>
</tr>
</table>
</form>
<script type="text/javascript">
var addyComplete;
// This is the callback function to initialise the address lookup script
function initAddy() {
addyComplete = new AddyComplete(document.getElementById("address1"));
addyComplete.fields = {
address1: document.getElementById("address1"),
address2: document.getElementById("address2"),
suburb: document.getElementById("suburb"),
city: document.getElementById("city"),
postcode: document.getElementById("postcode")
}
// Initialise the country value
var country = document.getElementById("country");
onCountryChange(country.options[country.selectedIndex].value);
}
function onCountryChange(value) {
if (!addyComplete) return;
// Enable/disable Addy based on the selected country
if (value === "NZL") {
addyComplete.enable();
} else {
addyComplete.disable();
}
}
</script>
<!-- for NZ country -->
<script src="./js/addy.js?nzKey=demo-api-key&country=nz&callback=initAddy" async defer></script>
<!-- or CDN -->
<!-- <script src="https://www.addysolutions.com/address-lookup/1.6.2/js/addy.min.js?nzKey=demo-api-key&country=nz&callback=initAddy" async defer></script> -->
<!-- for AU country -->
<!-- <script src="https://www.addysolutions.com/address-lookup/1.6.2/js/addy.min.js?auKey=demo-api-key&country=au&callback=initAddy" async defer></script> -->
<!-- or CDN -->
<!-- <script src="./js/addy.min.js?auKey=demo-api-key&country=au&callback=initAddy" async defer></script> -->
</body>
</html>