Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP - Dropdown function that keeps current page in focus
    primarykey
    data
    text
    <p>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:</p> <pre><code>function makeDropDown($page){ switch ($page){ case 'uploads': echo '&lt;center&gt;&lt;form action="pictures.php" action="get"&gt; &lt;select name="pictype"&gt; &lt;option value="uploads"&gt;Uploads&lt;/option&gt; &lt;option value="fromweb"&gt;From Web&lt;/option&gt; &lt;option value="wallpapers"&gt;Wallpapers&lt;/option&gt; &lt;option value="misc"&gt;Miscellaneous&lt;/option&gt; &lt;/select&gt; &lt;input type="submit" value = "Go!"/&gt; &lt;/form&gt;&lt;/center&gt;'; break; case 'fromweb': echo '&lt;center&gt;&lt;form action="pictures.php" action="get"&gt; &lt;select name="pictype"&gt; &lt;option value="fromweb"&gt;From Web&lt;/option&gt; &lt;option value="uploads"&gt;Uploads&lt;/option&gt; &lt;option value="wallpapers"&gt;Wallpapers&lt;/option&gt; &lt;option value="misc"&gt;Miscellaneous&lt;/option&gt; &lt;/select&gt; &lt;input type="submit" value = "Go!"/&gt; &lt;/form&gt;&lt;/center&gt;'; break; case 'wallpapers': echo '&lt;center&gt;&lt;form action="pictures.php" action="get"&gt; &lt;select name="pictype"&gt; &lt;option value="wallpapers"&gt;Wallpapers&lt;/option&gt; &lt;option value="uploads"&gt;Uploads&lt;/option&gt; &lt;option value="fromweb"&gt;From Web&lt;/option&gt; &lt;option value="misc"&gt;Miscellaneous&lt;/option&gt; &lt;/select&gt; &lt;input type="submit" value = "Go!"/&gt; &lt;/form&gt;&lt;/center&gt;'; break; </code></pre> <p>Any suggestions?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload