The Dropdown feature is failing to display HTML and CSS

I am having trouble displaying the dropdown with the attribute data-toggle=dropdown on the search input field {{form.query}}.

Do you have any solutions?

Here are the Bootstrap and jQuery links in the head section :

    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a1c3ceced5d2d5d3c0d1e1948f918f918cc3c4d5c090">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

And here is the JavaScript in the body :

    <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1e7c71716a6d6a6c7f6e5e2b302e302e337c7b6a7f2f">[email protected]</a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous"gt;</script>

Here is the HTML code:

<form class="dropdown" method="get">
       <input type="text" name="query" class="form-control" placeholder="Type Here" data-toggle="dropdown" required id="id_query">
    
       <ul class="dropdown-menu col-12 pl-2" role="menu" aria-labelledby="menu" id="list" style="display:inline-block;">
          <li role="presentation"> <a href="#" role="menuitem" tabindex="-1">Django</a></li>
           <div class="dropdown-divider"></div>
           <li role="presentation"> <a href="#" role="menuitem" tabindex="-1">Potato</a></li>
           <div class="dropdown-divider"></div>
           <li role="presentation"> <a href=&wuit;#" role="menuitem" tabindex="-1">Sleep</a></li>
       </ul> 
    
   <input type="submit" value="Search" class="btn btn-lg btn-primary col-12 my-2">                    
</form>

Answer №1

Could you please review the code link provided below? It should work for your needs. Make sure to include

id="dropdownMenuButton" data-bs-toggle="dropdown" aria-expanded="false"
in input

and

aria-labelledby="dropdownMenuButton"
in dropdown-menu

in accordance with the bootstrap documentation

Please visit this link: https://jsfiddle.net/yudizsolutions/8fnw0o46/11/

<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="41232e2e35323533203101746f716f716c2324352070">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cba9a4a4bfb8bfb9aabb8bfee5fbe5fbe6a9aebfaafa">[email protected]</a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous"></script>
<form class="dropdown" method="get">
  <input type="text" name="query" class="form-control" placeholder="Type Here" data-toggle="dropdown" id="dropdownMenuButton" data-bs-toggle="dropdown" aria-expanded="false" required id="id_query">

  <ul class="dropdown-menu col-12 pl-2" role="menu" aria-labelledby="dropdownMenuButton" id="list">
    <li role="presentation"> <a href="#" role="menuitem" tabindex="-1">Django</a></li>
    <div class="dropdown-divider"></div>
    <li role="presentation"> <a href="#" role="menuitem" tabindex="-1">Potato</a></li>
    <div class="dropdown-divider"></div>
    <li role="presentation"> <a href="#" role="menuitem" tabindex="-1">Sleep</a></li>
  </ul>

  <input type="submit" value="Search" class="btn btn-lg btn-primary col-12 my-2">
</form>

Answer №2

It is essential to utilize either a hyperlink or a button to activate the dropdown, rather than a text input.

Enclose both the dropdown toggle (button or link) and the dropdown menu inside .dropdown, or another element with position: relative; specified. Dropdowns can be activated by <a> or <button> elements for more versatile usage.

Visit this link for more examples.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Implementing MVC2 AJAX to dynamically set the UpdateTargetId depending on the response data

The situation: I'm currently developing a login form for an MVC2 application. My approach: The form is set up to submit to an MVC2 action that verifies the username and password. If the validation fails, the action returns the form (a partial view) ...

Unexpected outcomes with Django QuerySet slicing

While dynamically creating a Django query, I encountered unexpected results when using slice parameters. Specifically, when requesting queryset[0:10] and querset[10:20], I noticed that some of the same items were present in both query results. After condu ...

Sending Data in Angular JS

Looking for guidance on Angular JS as a newcomer. I have set up a form on my index.html page, and when the user fills in the details and hits submit, I want it to redirect to a details.html page where all the filled-in information can be displayed. HTML ...

Methods for parsing a jQuery Ajax response object without the need for a loop

Consider the following jQuery AJAX request: $.getJSON("getSearchSystems.php", {level: "full", data:this.label}, function(data){ //This method is unsuccessful. console.log(data.regionName); console.log(data.constellationName); console.l ...

I am unable to display media graphics within templates

I am experiencing issues displaying media images in my templates. Despite researching similar problems on Stackoverflow, none of the suggested solutions have resolved the issue for me. I have attempted adding 'load static' at the beginning of the ...

The width of a div element seems to mimic the width of the entire page inexplic

There is a page containing various div elements. HTML: <div class="utilitiesHeader"> <div id="utilitiesLogo"></div> <div id="utilitiesFIO">Name of user</div> </div> <div class="utilitiesContent"> <d ...

Incorporate custom styles into Joomla articles

Is there a way to apply custom styles to articles in Joomla without them getting deleted by the editor? <style> span{ color: #0099ff; } img{ float: right; } </style> <div> <h3> <span ...

Is your CSS not reflecting changes in Node.js?

I am having trouble getting the CSS to update in the browser using Browser Sync via Gulp on Node.js. What could be the issue? Below is my Gulp.js file: var themename = 'playtest haha 1'; var gulp = require('gulp'), // Prepare ...

What is the best way to reset an angularJS form after it has been submitted

I am trying to figure out a way to clear form fields on a modal window after the user executes the save method. I have attempted using $setPristine in AngularJS, but it's not working as expected. Any suggestions on how to achieve this task? Here is t ...

The collapsing menu is malfunctioning due to duplicate selectors

Although I have been learning HTML, CSS and jQuery, one area that always trips me up is selectors. Currently struggling with redundant selectors. I am attempting to customize the ul and li elements after collapsing the li, however, the selector doesn&apos ...

"Exploring the Power of Perl in Harnessing Html5 Server-S

I have been working on implementing server sent events to replace ajax long polling within my application. However, I have encountered an issue with my perl script where the sleep function is causing the sending stream to be blocked. #!/opt/lampp/bin/perl ...

jQuery: Invert the value within every function

After creating a dropdown and receiving values from the response, I encountered an issue. The reverse.config consists of two values: 1, 2. My goal is to print them in reverse order, so 2 should be printed before 1. I attempted using the reverse() functio ...

Content in Bootstrap not filling entire mobile screen

The content in this form does not stretch to full screen on mobile phones, but it appears properly on computers and tablets. Please advise on how to solve this issue. https://i.stack.imgur.com/S2XkS.jpg <link rel="stylesheet" href="https://maxcdn.bo ...

How can I insert PHP code within the style attribute of a div tag?

I tried implementing this code, but unfortunately it's not functioning properly. My goal is to take user-defined width and height inputs in PHP and use them to generate a shape. echo "<div style='width:<?php $sirina?>;height: <?php $v ...

JSON parsing successfully but failing to deliver expected results

Currently tackling my web design assignment that involves working with AJAX. I'm encountering an issue with the JSON.parse() function. The problem arises when I execute a GET request on my JSON database using AJAX: artist_list = $.ajax({ dataType ...

Can you provide a straightforward and easy-to-follow tutorial on implementing multiple databases in Django?

After going through various posts and the Django documentation, I am still struggling to make multiple databases work. As a newcomer to Django, I find myself feeling quite lost. Within my project, there is one app that needs to utilize an existing vo.sqli ...

The hyperlink appears to be malfunctioning with an additional border surrounding it within a pop-up window

I am facing an issue with a link <a> not functioning properly with a popup dialog on . Additionally, there seems to be a border that appears around the <a> when the popup initially displays. If you click on "Leer más" for any product, you can ...

I am interested in implementing a "slide up" effect for the "slide menu" when it loses focus

When I focus out of the asmenu class, I attempt to trigger a 'slide up' effect. However, if I select two checkboxes from the child elements within the asmenu class, the focusout event is still triggered. Ideally, I would like the 'slide up& ...

Select numerous files and conveniently delete them using the angular delete button

Background: In one of my tables, there is a column where users can either choose or upload files as input. I have implemented a feature that allows users to select multiple files at once. Issue at Hand: What I am trying to achieve is to have an 'x&ap ...

Looking to update the page title on a WordPress website

I would like to update the title of a page that has been created using a category link. Specifically, I need to change the page title to "News." Although I have explored customization options, I am unable to directly modify the text. Thus, I am looking f ...