Created
September 11, 2023 05:30
-
-
Save mdibrahimk48/8fa0513e76286064e31073111f92a4f3 to your computer and use it in GitHub Desktop.
To display the selected data from a dropdown menu, you typically use a <select> element for the dropdown and another element, such as a <span>, to display the selected value. Here’s an example of how you can display the selected data correctly:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<label for="pick-up">Pick-up Location:</label> | |
<select id="pick-up" name="pick-up"> | |
<option value="">Select an option</option> | |
<option value="Airport Ngurah Rai">Airport Ngurah Rai</option> | |
<option value="Amed">Amed</option> | |
<!-- Add more options here --> | |
</select> | |
Selected Pick-up Location: <span id="selected-pick-up"></span> | |
<script> | |
const pickUpSelect = document.getElementById('pick-up'); | |
const selectedPickUp = document.getElementById('selected-pick-up'); | |
pickUpSelect.addEventListener('change', function() { | |
selectedPickUp.textContent = pickUpSelect.value; | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment