This approach utilizes the power of HTML, CSS, and jQuery to create a solution. If you're looking for a solution tailored to Bootstrap, you can refer to How to use input field as toggle for bootstrap 4 dropdown.
Now, let's dive in.
Start by setting up a standard form with a number input type and add the disabled
attribute to prevent the cursor from appearing when clicking on the form (
<input type="number" disabled>
). Next, create a dropdown menu (likely a
<div>
positioned directly below the input) and assign it a class name of your choice (for the purpose of this explanation, let's assume you name it
.passengerInput
).
To initially hide the dropdown, use the
$(".passengerInputDropdown").hide()
function within your JavaScript code.
Then, when the form is clicked, toggle the dropdown visibility by executing
$(".passengerInput").toggle()
. Here's a basic implementation example:
$(".passengerInput").on("click", () => {
$(".passengerInputDropdown").toggle();
})
Feel free to reach out if you need further clarification on this method!