Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨Added a localStorage and refactored CSS ✨ #122

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ <h3>Romantic Getaway</h3>
</section>

<!-- Cab or Auto Booking -->

<section
id="cab-booking"
class="cab-booking-section"
Expand All @@ -292,6 +293,7 @@ <h3>Romantic Getaway</h3>
margin-top: 10px;
"
>

Book a Cab or Auto
</h2>
<p style="margin-left: 40px; font-size: 1.5em; margin-bottom: 10px">
Expand Down Expand Up @@ -391,8 +393,88 @@ <h3>Romantic Getaway</h3>
Book now
</button>
</form>
</section> -->
<section id="cab-booking" class="cab-booking-section">
<h2>Book a Cab or Auto</h2>
<p>Book a cab or auto with ease</p>

<form id="cab-booking-form">
<label for="pickup-location">Pickup Location:</label>
<input
type="text"
id="pickup-location"
name="pickup-location"
placeholder="Enter pickup location"
required />

<label for="drop-location">Drop Location:</label>
<input
type="text"
id="drop-location"
name="drop-location"
placeholder="Enter drop location"
required />

<label for="vehicle-type">Vehicle Type:</label>
<select id="vehicle-type" name="vehicle-type" required>
<option value="cab">Cab</option>
<option value="auto">Auto</option>
</select>

<label for="travel-date">Travel Date:</label>
<input type="date" id="travel-date" name="travel-date" required />

<label for="travel-time">Travel Time:</label>
<input type="time" id="travel-time" name="travel-time" required />

<input type="submit" value="Book Now" />
</form>

<div id="form-message" class="form-message"></div>
</section>

<script>
document.addEventListener("DOMContentLoaded", function () {
// Load stored data from localStorage if exists
const storedData = localStorage.getItem("cabBookingData");
if (storedData) {
const formData = JSON.parse(storedData);
document.getElementById("pickup-location").value = formData.pickupLocation;
document.getElementById("drop-location").value = formData.dropLocation;
document.getElementById("vehicle-type").value = formData.vehicleType;
document.getElementById("travel-date").value = formData.travelDate;
document.getElementById("travel-time").value = formData.travelTime;
}

// Form submission handler
document.getElementById("cab-booking-form").addEventListener("submit", function (event) {
event.preventDefault(); // Prevent form submission

// Capture form data
const formData = {
pickupLocation: document.getElementById("pickup-location").value,
dropLocation: document.getElementById("drop-location").value,
vehicleType: document.getElementById("vehicle-type").value,
travelDate: document.getElementById("travel-date").value,
travelTime: document.getElementById("travel-time").value,
};

// Store data in localStorage
localStorage.setItem("cabBookingData", JSON.stringify(formData));

// Display success message
document.getElementById("form-message").innerText = "Cab booked successfully!";

// Clear form
document.getElementById("cab-booking-form").reset();
});
});
</script>





<!-- recommendations -->
<section id="recommendations" class="recommendations-section">
<h2>Personalized Recommendations</h2>
Expand Down
2 changes: 2 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,7 @@ body.dark-mode {
transition: transform 0.3s ease, color 0.3s ease;
}


.twitter:hover {
background-color: #1e97e3; /* Twitter's official blue color */
transform: scale(1.1);
Expand Down Expand Up @@ -998,3 +999,4 @@ body.dark-mode {

/* Extra large devices (large laptops and desktops, 1200px and up) */
/*@media only screen and (min-width: 1200px) {...}*/

Loading