# Navigation through Dashboard

A drop-down menu will display all of the Dashboards present in the Ubidots account, upon selecting one, said dashboard will be opened in a new browser tab.

HTML:

```html
<div>
    <h1>Navigate through your Dashboards</h1>
    <select id="dashboardsList"></select>
</div>
```

Javascript:

```javascript
var token = ubidots.token;
const dashboardsDropdown = document.getElementById('dashboardsList');
dashboardsDropdown.addEventListener('change', handleSelectionChange);

getAllDashboards(token).then((data) =>
{
    // Iterate over the data and create options
    const dropdown = document.getElementById('dashboardsList');
    data.results.forEach(item => 
    {
        const option = document.createElement('option');
        option.value = item.id; // Adjust the value according to your data
        option.text = item.label; // Adjust the displayed text according to your data
        option.label = item.label;
        dropdown.appendChild(option);
    });
});

function handleSelectionChange() 
{
    const dashboardID = this.value; // Get the selected value
    const url = `https://industrial.ubidots.com/app/dashboards/${dashboardID}`;
    window.open(url, '_blank');
   
}

async function getAllDashboards(ubidotsToken)
{
    const url = "https://industrial.api.ubidots.com/api/v2.0/dashboards/";
    const method = "GET";
    const req = await fetchWrapper(url, method, ubidotsToken);
    return req;
}

async function fetchWrapper(url, method, token = null, payload = null)
{
	const options =
	{
    	method: method,
		headers: {'Content-Type' : 'application/json'}
	};

	if (payload)
	{
    	options.body = JSON.stringify(payload);
  	}

  	if (token)
	{
    	options.headers['X-Auth-Token'] = token;
  	}

	const response = await fetch(url, options);
	const jsonData = await response.json();
	return jsonData;
}

```

The following is the resulting Widget:

<figure><img src="https://884329393-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MhzNRg0B4ECiNXc093G%2Fuploads%2FJ7npcUSlJnWXe8SAEhuY%2FPeek%202023-05-16%2011-58.gif?alt=media&#x26;token=3e7793e6-5f3c-46d9-b319-27e75a875165" alt=""><figcaption></figcaption></figure>
