Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3853070
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:24:46+00:00 2026-05-19T17:24:46+00:00

I have a drop-down navigation that brings the user to the page selected in

  • 0

I have a drop-down navigation that brings the user to the page selected in the drop-down once the user clicks a button. I have a function that takes in the page section title as a parameter and builds a new drop-down with that page on top of the list, so that each page you navigate to will remain in focus in the drop-down. The function is a massive switch case with a lot of repetitive code and I know there’s an easier and cleaner way of doing this… I’m just having trouble thinking of a solution. Here’s a code snippet, I won’t post the entire switch case:

function makeDropDown($page){ 
switch ($page){
    case 'uploads':
      echo '<center><form action="pictures.php" action="get">
         <select name="pictype">
         <option value="uploads">Uploads</option>
         <option value="fromweb">From Web</option>
         <option value="wallpapers">Wallpapers</option>
         <option value="misc">Miscellaneous</option>
         </select>
         <input type="submit" value = "Go!"/>
         </form></center>'; break;
   case 'fromweb':
      echo '<center><form action="pictures.php" action="get">
         <select name="pictype">
         <option value="fromweb">From Web</option>
         <option value="uploads">Uploads</option>
         <option value="wallpapers">Wallpapers</option>
         <option value="misc">Miscellaneous</option>
         </select>
         <input type="submit" value = "Go!"/>
         </form></center>'; break;
   case 'wallpapers':
      echo '<center><form action="pictures.php" action="get">
         <select name="pictype">
         <option value="wallpapers">Wallpapers</option>
         <option value="uploads">Uploads</option>
         <option value="fromweb">From Web</option>
         <option value="misc">Miscellaneous</option>
         </select>
         <input type="submit" value = "Go!"/>
         </form></center>'; break;

Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T17:24:47+00:00Added an answer on May 19, 2026 at 5:24 pm

    Instead of moving the selected item to the top of the list, why not try using the selected attribute of the option items. This will initialize the select box to the selected option. simply echo selected in the option that matches the value of $page

    function makeDropDown($page){ 
        echo '<center><form action="pictures.php" action="get">';
        echo '    <select name="pictype">';
        echo '        <option value="uploads"'.(($page=="uploads")? " selected":"").'>Uploads</option>';
        echo '        <option value="fromweb"'.(($page=="fromweb")? " selected":"").'>From Web</option>';
        echo '        <option value="wallpapers"'.(($page=="wallpapers")? " selected":"").'>Wallpapers</option>';
        echo '        <option value="misc"'.(($page=="misc")? " selected":"").'>Miscellaneous</option>';
        echo '    </select>';
        echo '    <input type="submit" value = "Go!"/>';
        echo '</form></center>';
    }
    

    This way, if $page=='misc', your HTML will result this way

    <center><form action="pictures.php" action="get">
        <select name="pictype">
            <option value="uploads">Uploads</option>
            <option value="fromweb">From Web</option>
            <option value="wallpapers">Wallpapers</option>
            <option value="misc" selected>Miscellaneous</option>
        </select>
        <input type="submit" value = "Go!"/>
    </form></center>'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a drop-down list hardcoded in an MVC View User Control page and
so I have a drop down navigation that appears on hover and I'm trying
Drop Down navigation that I have created makes the text in li to go
I have a site w/ an image gallery (Portfolio) page. There is drop-down navigation
I have a navigation bar with some nodes that have a drop down menu
I have a drop down navigation that works perfectly when positioned via a left
I have a drop down list that has options that need to be passed
I have a drop down menu in an ASPX page along the lines of:
I have a drop down list that triggers an updatepanel when the index is
I have a standard drop-down menu that uses jQuery to hide the children li

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.