Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Shivamyadav's avatar

Dropdown link ? error

when i click my dropdown link it takes me to the other page that's fine .. i wnat to open the dropdown list untill it is selected any link of the dropdown link ..

my code is here , where button tag is my main students and its child are add students and show students when it takes me to the other page there also i have used a components to all pages header, navabar,footer etc

<li>
        <button id="student" class="flex flex-row  w-full rounded-lg items-center h-12 mb-2 transform hover:translate-x-2 transition-transform ease-in duration-200 text-gray-500
          ">
          <span class="inline-flex items-center justify-center h-12 w-12 text-lg "><i class="bx bx-music"></i></span>
          <span class="text-sm font-medium">Students</span>
        </button>
        <ul id="students-nav" class="hidden bg-gray-200 rounded-lg">
          <li>
            <a href="<?php echo isset($_SESSION['email']) ? "/forms/student/" : "require __DIR__ . /../../error/404error.php" ?>" class="flex flex-row items-center h-12 transform hover:translate-x-2 transition-transform ease-in duration-200 text-gray-500
              <?php echo urlIs("/forms/student/index.php") ? "bg-sky-400 p-2 rounded-lg font-bold text-white animate-bounce" : "" ?>">
              <span class=" inline-flex items-center justify-center h-12 w-12 text-lg "><i class=" bx bx-music"></i></span>
              <span class="text-sm font-medium">Add Students</span>

            </a>
          </li>
          <li >
            <a id="show" href="<?php echo isset($_SESSION['email']) ? "/forms/student/show.php" : "require __DIR__ . /../../error/404error.php" ?>" class="flex flex-row items-center h-12  transform hover:translate-x-2 transition-transform ease-in duration-200 text-gray-500
              <?php echo urlIs("/forms/student/show.php") ? "bg-sky-400 p-2 rounded-lg font-bold text-white animate-bounce" : "" ?>">
              <span class="inline-flex items-center justify-center h-12 w-12 text-lg "><i class="bx bx-music"></i></span>
              <span class="text-sm font-medium">Show Students</span>

            </a>
          </li>
        </ul>
      </li>
0 likes
4 replies
Yorki's avatar

What is the problem exactly? What do you want to achieve?

Shivamyadav's avatar

@Yorki when i click to the link the it takes me to the other page and refreshed and the hidden field ul tag is hidden .., not visible (open)

Shivamyadav's avatar

i have set by js to un hidden when a user clicks on the button tag , thats working but when i try to use the add student and show students link it render on another page and js code is no longer working.. means when the link render me to the next page i want to be open the ul tag list link , as long as a link is clicked

Yorki's avatar

@Shivamyadav you need to check somehow if the ul tag should be hidden or not:

<ul id="students-nav" class="<?php strpos($_SERVER['REQUEST_URI'], 'forms/student') !== false ? '' : 'hidden' ?> bg-gray-200 rounded-lg">

Please or to participate in this conversation.