ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Question about links in Category Dropdown Menu

September 05, 2010 3:43am

Subscribe [4]
  • #1 / Sep 05, 2010 3:43am

    shinokada

    144 posts

    In EE document, there is an example of “Category Dropdown Menu”.

    <form name="catmenu" action="">
    <select name="selcat">
    <option value="">--Select Category--</option>
    {exp:channel:categories channel="yourchannel" style="linear"}
    <option value="{path='channel'}">{category_name}</option>
    {/exp:channel:categories}
    </select>
    </form>


    When I used this in EE 2 book, it produced the following code.

    <form name="catmenu" action="">
    <select name="selcat">
    <option value="">--Select Category--</option>
    <option value="http://localhost/ee/index.php/channel/category/news">News</option>
    <option value="http://localhost/ee/index.php/channel/category/world">World</option>
    ...
    ...


    I need the link to be like this.

    http://localhost/ee/index.php/news_articles/page/category/world

    rather than

    http://localhost/ee/index.php/channel/category/world.


    Q1. What do I need to change in the original code?

    Q2. What is this line in the original code doing?

    onchange=“location=document.catmenu.selcat.options[document.catmenu.selcat.selectedIndex].value

  • #2 / Sep 05, 2010 5:35pm

    Greg Salt

    3988 posts

    Hi shinokada,

    You can always build the links manually without using the path variable if you have a specific requirement. The Javascript is going to immediately go to whatever URL is selected in the dropdown. You can safely remove that if you wish.

    Cheers

    Greg

  • #3 / Dec 14, 2010 11:45am

    Jason Turcotte

    102 posts

    Hi shinokada,

    You can always build the links manually without using the path variable if you have a specific requirement. The Javascript is going to immediately go to whatever URL is selected in the dropdown. You can safely remove that if you wish.

    Cheers

    Greg

    How would I modify the original code to execute the search when a user clicks a submit button rather than automatically going to the URL when the dropdown menu is changed?

  • #4 / Dec 14, 2010 5:18pm

    Ingmar

    29245 posts

    You probably need to replace the onchange() command with onsubmit(). Moving to the CodShare Corner.

  • #5 / Dec 14, 2010 6:09pm

    Jason Turcotte

    102 posts

    Thanks for moving the post, but changing to “onsubmit” did not do what I had hoped.

    You probably need to replace the onchange() command with onsubmit(). Moving to the CodShare Corner.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases