<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Select2 Example</title>
  
  <!-- Include Select2 CSS -->
  <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet" />
  
  <!-- Include jQuery -->
  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  
  <!-- Include Select2 JS -->
  <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/js/select2.min.js"></script>

  <style>
    /* Optional: Styling for the select container */
    .select-container {
      width: 300px;
      margin: 50px;
    }
  </style>
</head>
<body>

  <div class="select-container">
    <h2>Searchable Select Box with Select2</h2>
    <select id="mySelect">
      <option value="apple">Apple</option>
      <option value="banana">Banana</option>
      <option value="cherry">Cherry</option>
      <option value="date">Date</option>
      <option value="elderberry">Elderberry</option>
      <option value="fig">Fig</option>
      <option value="grape">Grape</option>
      <option value="honeydew">Honeydew</option>
    </select>
  </div>

  <script>
    // Initialize Select2
    $(document).ready(function() {
      $('#mySelect').select2({
        placeholder: "Select a fruit",  // Optional placeholder text
        allowClear: true                // Optional: allows clearing the selection
      });
    });
  </script>

</body>
</html>
