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.

How to get selected value from select element into a variable or something I can use within EE?

December 12, 2011 4:55pm

Subscribe [2]
  • #1 / Dec 12, 2011 4:55pm

    darrenlc

    11 posts

    In ExpressionEngine I have a news template that displays news items. I am trying to implement a select element that allows the user to select a particular year and then see only news items entered within that year.

    <select name="select_year">
                <option value="">Select year</option>
                <option value="2011">2011</option>
                <option value="2010">2010</option>
                <option value="2009">2009</option>
            </select>   
    
                        {exp:channel:entries
                    channel="news-items"
                    disable="categories|category_fields|trackbacks"
                    dynamic="off"
                    require_entry="yes"
                    sort="desc"
                    search:news-item-featured="featured"
                    limit="1"}
    
                    <div align="left">
                      <h2 align="center">{title}</h2>
                    </div>
    
                    {if news-item-main-image}
                        {exp:imgsizer:size src="{news-item-main-image}" width="352"}
                            img align="middle" width="352" src="{sized}">
                        {/exp:imgsizer:size}
                    {/if}
    
                    {news-item-intro-text}
    
                    <a*h*r*e*f="{title_permalink='news-item'}">Click here to read the full story. </a>
    
                {/exp:channel:entries}
    
    
    
    
                <h3>News History</h3>
    <p>            <ul></p>
    
    <p>            {exp:channel:entries<br />
                    channel="news-items"<br />
                    disable="categories|category_fields|trackbacks"<br />
                    dynamic="off"<br />
                    require_entry="yes"<br />
                    limit="19"<br />
                    paginate="bottom"<br />
                    paginate_base="/news"}</p>
    
    <p>                    <li></p><h3><a*h*r*e*f="{title_permalink='news-item'}">{title}</a></h3>
    <p>                    <input type="hidden" value="" name="news_id">{entry_date format="%n/%j/%Y"} - </li></p>
    
    <p>                {paginate}</p>
    
    <p>                    </ul><br />
                        </p>
    
    <p><br />
                            {pagination_links}</p>
    
    <p>                        {current_page} of {total_pages}<br />
                         </p>
    
    <p>                {/paginate}</p>
    
    <p>            {/exp:channel:entries}

    The code displays all news items currently. This consists of a featured news item at the very top and a hyperlinked list of all previous news items beneath it.

    Is there a way I can specify a variable to store the selected value from the select element at the very top so that I can use it with the news-items below? Or is there perhaps a better way?

  • #2 / Dec 16, 2011 6:55pm

    e-man

    1816 posts

  • #3 / Dec 18, 2011 7:41pm

    darrenlc

    11 posts

    Thank you.

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

ExpressionEngine News!

#eecms, #events, #releases