Search code examples
phphtmlurlhref

HTML - href adds a # to current URL


I'm creating a "web store". I've created a navbar using Bootstrap. I have 3 php files: index, category and article, all .php

                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Categories<span class="caret"/></a>
                        <ul class="dropdown-menu">
                            <li><a href="categorias.php?categoria=Computacion">Compu</a></li>
                            <li><a href="categorias.php?categoria=Mascotas" >Animals & Pets</a></li>
                            <li><a href="categorias.php?categoria=Oficina">Office</a></li>
                            <li><a href="categorias.php?categoria=Media">Music & Movies</a></li>
                        </ul>
                    </li>

The "Category" link works only as a dropdown, you click it and it shows the submenu.

<a href="#" class="dropdown-toggle" data-toggle="dropdown">Categorías<span class="caret"/></a>

This code is in all 3 files, but it only works on index and category. When I click it on the article.php file it only adds a "#" to the current URL.

localhost/store/article.php?id=1 -> localhost/store/article.php?id=1#

I'm using the id to show the selected article's info from a database. I use it too on the category.php file but the dropdown link works there. Everything else works fine, except that link.

Am I missing something?

PS. I'm only using HTML and PHP in my files.


Solution

  • Sounds like you forgot to import the necessary bootstrap dependents on the article page.

    Necessary Dependents

    CSS

    1. bootstrap.min.css , or theme if you are using

    JavaScript files

    1. jQuery
    2. bootstrap.min.js

    Sounds like a JS issue.