Travel websites often help visitors compare activities.
They display cards with photographs, prices, descriptions, and filters.
But there's a problem developers need to consider.
What happens when a listed activity is no longer available?
A beautifully designed comparison page can still mislead people if it presents historical services as something they can book today.
Let's explore a better approach.
We'll build a simple JavaScript comparison tool inspired by people researching the best scuba diving Maui experiences around Lahaina and nearby Kaanapali.
Our interface will let users:
- Filter activities by experience level
- Search activity descriptions
- See clear availability labels
- Distinguish example data from verified services
- Understand when they need to contact a provider
We'll use plain HTML, CSS, and JavaScript.
No framework or API key required.
1. The Problem With a Typical Activity Card
Consider an imaginary travel listing:
Amazing Two-Tank Dive
Experience: Certified divers
Duration: 4 hours
Book now!
It looks straightforward.
But it leaves out important information.
Is the activity operating?
Is the duration still correct?
Does the experience match the participant's qualifications?
And has anyone checked these details recently?
A better interface should make uncertainty visible instead of hiding it.
Our project will use three status values:
const STATUS = {
AVAILABLE: "available",
UNAVAILABLE: "unavailable",
UNVERIFIED: "unverified"
};
These values have different meanings.
available means a reliable source has confirmed that an activity is operating.
unavailable means the activity is not currently offered according to the source being used.
unverified means we don't have enough current information.
A production website should never automatically treat an unverified activity as available.
2. Create a Small Project
Start with this structure:
dive-comparison/
index.html
styles.css
app.js
We'll create the interface first, followed by the example dataset and filtering logic.
All records in this tutorial are fictional demonstration entries.
They are not current Dive Maui products, actual tour listings, or independently verified booking options.
3. Build the HTML Interface
Create index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1">
<title>Scuba Activity Comparison</title>
<link rel="stylesheet" href="styles.css">
<script src="app.js" defer></script>
</head>
<body>
<main class="container">
<header>
<h1>Compare Scuba Activities</h1>
<p>
Explore example activities by experience level
and availability status.
</p>
<p class="notice">
Demo data only. These are not bookable tours.
</p>
</header>
<section class="filters"
aria-label="Activity filters">
<div>
<label for="experience">
Experience level
</label>
<select id="experience">
<option value="all">All levels</option>
<option value="beginner">Beginner</option>
<option value="certified">Certified</option>
</select>
</div>
<div>
<label for="search">
Search activities
</label>
<input
id="search"
type="search"
placeholder="Search by activity or habitat"
>
</div>
</section>
<p id="result-count" role="status"></p>
<section id="results"
class="results"
aria-label="Activity results">
</section>
</main>
</body>
</html>
The interface uses native form controls.
Each input has an associated label.
We also include a visible notice explaining that the project uses demonstration data.
That matters because a demo should not look like a live booking platform.
4. Add the Example Activities
Now create app.js.
Start with a small dataset:
const activities = [
{
id: 1,
name: "Introductory Reef Experience",
level: "beginner",
habitat: "Coastal reef",
status: "unverified",
description: "Example supervised beginner program."
},
{
id: 2,
name: "Certified Reef Exploration",
level: "certified",
habitat: "Rocky reef",
status: "unavailable",
description: "Example guided activity for certified divers."
},
{
id: 3,
name: "Coastal Skills Session",
level: "certified",
habitat: "Training environment",
status: "unverified",
description: "Example skills review for trained participants."
}
];
Notice what we haven't included.
There are no fabricated prices.
There are no invented operator names.
There are no guaranteed wildlife sightings.
And none of the records claims to represent a current Lahaina diving service.
This dataset is useful for demonstrating the interface without misleading readers.
5. Filter Activities With JavaScript
We can use JavaScript's filter() method to select matching records.
Add this function below the dataset:
function filterActivities(items, level, query) {
const searchTerm = query.trim().toLowerCase();
return items.filter((item) => {
const levelMatches =
level === "all" || item.level === level;
const searchableText = [
item.name,
item.habitat,
item.description
].join(" ").toLowerCase();
const searchMatches =
searchableText.includes(searchTerm);
return levelMatches && searchMatches;
});
}
The function checks two conditions.
First, does the activity match the selected experience level?
Second, does the search text appear in the activity's content?
Both conditions must match.
This is a simple pattern that works well for small client-side datasets.
For larger applications, server-side filtering or a dedicated search service may be more appropriate.
6. Give Every Status a Clear Label
A status should be understandable without relying on color.
Let's create a function for that.
function getStatusLabel(status) {
const labels = {
available: "Confirmed available",
unavailable: "Currently unavailable",
unverified: "Availability not verified"
};
return labels[status] || "Status unknown";
}
Why return a fallback?
Because real-world datasets can contain missing or unexpected values.
We don't want an unknown status to become an accidental booking promise.
The fallback stays conservative.
For a real business website, availability should be confirmed by an appropriate source and reviewed regularly.
7. Render the Activity Cards
Next, we need to show the matching activities.
To keep the example safe and easy to maintain, we'll build the DOM using createElement() and textContent.
This avoids inserting arbitrary dataset text as HTML.
function createActivityCard(activity) {
const card = document.createElement("article");
card.className = "activity-card";
const heading = document.createElement("h2");
heading.textContent = activity.name;
const level = document.createElement("p");
level.textContent =
`Experience: ${activity.level}`;
const habitat = document.createElement("p");
habitat.textContent =
`Habitat: ${activity.habitat}`;
const description = document.createElement("p");
description.textContent = activity.description;
const status = document.createElement("p");
status.className = "status";
status.dataset.status = activity.status;
status.textContent =
getStatusLabel(activity.status);
card.append(
heading,
level,
habitat,
description,
status
);
return card;
}
This card includes useful information without showing a misleading "Book Now" button.
In a real application, a booking action should only appear when the service is actually available and the booking system is appropriately connected.
8. Connect the Filters to the Interface
Now we can finish app.js.
Add the following code after the previous functions:
const experienceSelect =
document.querySelector("#experience");
const searchInput =
document.querySelector("#search");
const results =
document.querySelector("#results");
const resultCount =
document.querySelector("#result-count");
function render() {
const matches = filterActivities(
activities,
experienceSelect.value,
searchInput.value
);
results.replaceChildren();
matches.forEach((activity) => {
results.appendChild(
createActivityCard(activity)
);
});
if (matches.length === 0) {
const message = document.createElement("p");
message.textContent =
"No example activities match these filters.";
results.appendChild(message);
}
resultCount.textContent =
`${matches.length} example activities found.`;
}
experienceSelect.addEventListener("change", render);
searchInput.addEventListener("input", render);
render();
Now the interface updates when the visitor changes the selected experience level or enters search text.
The initial render() call makes sure that the example activities appear when the page loads.
This is a small feature, but it makes the dataset easier to explore.
9. Make the Layout Responsive
Create styles.css:
:root {
--text: #203746;
--accent: #075a7a;
--border: #d6e4e9;
--surface: #f4f9fb;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: Arial, sans-serif;
line-height: 1.6;
color: var(--text);
background: #fff;
}
.container {
max-width: 960px;
margin: auto;
padding: 32px 20px;
}
h1 {
font-size: clamp(1.8rem, 4vw, 2.5rem);
}
.notice {
padding: 14px;
background: #fff2d5;
border-left: 4px solid #9b6500;
}
.filters {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 16px;
margin: 28px 0;
}
label {
display: block;
font-weight: bold;
margin-bottom: 8px;
}
input,
select {
width: 100%;
padding: 12px;
border: 1px solid #839ba8;
border-radius: 6px;
font: inherit;
}
input:focus-visible,
select:focus-visible {
outline: 3px solid #b75b24;
outline-offset: 2px;
}
.results {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 18px;
}
.activity-card {
padding: 22px;
border: 1px solid var(--border);
background: var(--surface);
border-radius: 12px;
}
.activity-card h2 {
margin-top: 0;
font-size: 1.25rem;
}
.status {
font-weight: bold;
padding-top: 8px;
}
.status[data-status="unavailable"] {
color: #8f2525;
}
.status[data-status="unverified"] {
color: #765000;
}
.status[data-status="available"] {
color: #21643b;
}
@media (max-width: 640px) {
.filters,
.results {
grid-template-columns: 1fr;
}
}
The page now adapts to smaller screens.
We use text labels alongside color to show availability.
A visitor who cannot distinguish the status colors can still read the information.
10. What About Ranking the Results?
Here's where developers should be careful.
An activity comparison tool might be tempted to assign numerical scores.
For example:
Activity A: 98/100
Activity B: 92/100
Activity C: 87/100
But where do those scores come from?
If they are based on arbitrary assumptions, they can mislead users.
Scuba diving suitability depends on factors such as certification, recent experience, environmental conditions, and the specific program.
There is no universal ranking that makes one dive appropriate for every participant.
For this tutorial, we deliberately avoid ranking activities.
The interface filters descriptive information instead.
In a production application, rankings should be supported by clear, documented criteria, and they should never replace eligibility or safety assessments.
11. A Real Example From Lahaina, Maui
Dive Maui / Hawaiian Rafting Adventures is a family-run scuba and ocean activity business with a listed address at 1223 Front Street in Lahaina.
Its official website includes descriptions of diving trips, scuba training, and equipment-related services.
However, several previously advertised trips and courses are marked unavailable following operational challenges associated with the 2023 Lahaina wildfires.
For example, the company's two-tank boat diving page and Open Water Diver course page contain notices that those experiences are currently unavailable.
This is a useful case study for developers.
A content scraper might collect a trip title, duration, and published price without recognizing an availability notice.
A comparison interface could then accidentally show an outdated offering as bookable.
That is why a real application needs reliable status information, human review when appropriate, and clear handling of uncertainty.
Developers researching Dive Maui's scuba diving information near Lahaina can examine the official website as an example of why historical service descriptions and current notices must be interpreted together.
Our JavaScript dataset is fictional and should not be mistaken for the business's actual inventory.
12. Add Verification Dates in a Real Application
Availability is not permanent.
A service that is confirmed today could change later.
A useful production data model might include:
const service = {
name: "Example Coastal Dive",
status: "unverified",
verifiedAt: null,
sourceType: "official-business",
needsReview: true
};
The field verifiedAt should only be populated after an actual verification takes place.
Avoid using the current date automatically if nobody has checked the service.
You could also add a review workflow that flags older records for rechecking.
This approach makes it easier to distinguish data that has been confirmed from data that merely exists in the system.
13. Test Before Publishing
Open index.html in your browser.
Try these checks:
- Confirm all three example cards appear.
- Select the beginner filter.
- Confirm only the introductory example remains.
- Clear the filter and search for "reef".
- Search for a term with no matches.
- Check that the empty-results message appears.
- Resize the page to a mobile width.
- Navigate through the filters using a keyboard.
- Confirm no example card displays a booking button.
- Verify that every record has a clear availability label.
These tests cover the basic interaction.
For a production site, you would also want automated tests, accessibility testing, and a reliable process for reviewing business data.
Final Thoughts
A travel comparison interface can do more than arrange attractive cards on a screen.
It can help people understand what is known, what remains uncertain, and what questions still need answers.
For a subject like scuba diving around Lahaina and Kaanapali, those distinctions matter.
The right experience depends on the participant, the conditions, professional requirements, and actual service availability.
Our small vanilla JavaScript project demonstrates how to make that information easier to explore without inventing ratings or presenting old listings as current offers.
The technical foundation is simple.
Filter the data.
Render the results.
Explain the status.
And avoid making promises the data cannot support.
A useful comparison tool doesn't just help people find options. It helps them understand which information they can trust.
Top comments (0)