> For the complete documentation index, see [llms.txt](https://docs.mapbox.com/mapbox-search-js/ja/llms.txt)

# Add Address Autofill to an HTML form

This example implements [Address Autofill](https://docs.mapbox.com/mapbox-search-js/ja/api/web/autofill/) to automatically add suggestions to the address input of an existing HTML form. It uses the [`autofill`](https://docs.mapbox.com/mapbox-search-js/ja/api/web/autofill/#autofill) method of Address Autofill. For other ways to use Address Autofill, see [Using Address Autofill](https://docs.mapbox.com/mapbox-search-js/ja/guides/autofill/web/#using-address-autofill) from the Quick start guide.

Address Autofill works with [browser HTML autocomplete tags](https://web.dev/learn/forms/autofill/) and form inputs must have `autocomplete` attributes declared for Address Autofill to work.

**JavaScript**

```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Add Address Autofill to an HTML form</title>
<!-- Default styling. Feel free to remove! -->
<link href="https://api.mapbox.com/mapbox-assembly/v1.3.0/assembly.min.css" rel="stylesheet">
<script id="search-js" defer="" src="https://api.mapbox.com/search-js/v1.6.0/web.js"></script>
</head>
<body>
<form class="prose flex flex--column">
    <h3>Shipping</h3>
    <input class="input mb12 bg-white" name="address" autocomplete="shipping address-line1" placeholder="Address">
    <input class="input mb12 bg-white" name="apartment" autocomplete="shipping address-line2" placeholder="Apartment">
    <div class="flex">
        <input class="input mb12 bg-white" name="city" autocomplete="shipping address-level2" placeholder="City">
        <input class="input mb12 ml6 bg-white" name="state" autocomplete="shipping address-level1" placeholder="State">
        <input class="input mb12 ml6 bg-white" autocomplete="shipping postal-code" placeholder="ZIP / Postcode">
    </div>

    <h3>Billing</h3>
    <input class="input mb12 bg-white" name="address" autocomplete="billing address-line1" placeholder="Address">
    <input class="input mb12 bg-white" name="apartment" autocomplete="billing address-line2" placeholder="Apartment">
    <div class="flex">
        <input class="input mb12 bg-white" name="city" autocomplete="billing address-level2" placeholder="City">
        <input class="input mb12 ml6 bg-white" name="state" autocomplete="billing address-level1" placeholder="State">
        <input class="input mb12 ml6 bg-white" name="postcode" autocomplete="billing postal-code" placeholder="ZIP / Postcode">
    </div>
</form>
<script>

// TO MAKE THE MAP APPEAR YOU MUST
// ADD YOUR ACCESS TOKEN FROM
// https://account.mapbox.com
const ACCESS_TOKEN = 'YOUR_MAPBOX_ACCESS_TOKEN';
window.addEventListener('load', () => {

    const collection = mapboxsearch.autofill({
        accessToken: ACCESS_TOKEN
    });
});
</script>

</body>
</html>
```