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 9172011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:14:36+00:00 2026-06-17T16:14:36+00:00

I am trying to display an dropdown list with smarty html_options. It shows the

  • 0

I am trying to display an dropdown list with smarty html_options. It shows the dropdown nicely but output values as 0,1,2,3,4,5.

But I want values to be 100,150,200,250,300,350.

======PHP =========

$choice_set=array("A","B","C","D","E","F");
$choice_values=array(100,150,200,250,300,350);
$choice=250;

=====SMARTY=========

<select name="location">
{html_options values=$choice_values options=$choice_set selected=$choice}
</select>

Please help me to sort this out.

  • 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-06-17T16:14:37+00:00Added an answer on June 17, 2026 at 4:14 pm

    From their docs, it looks like you forgot to stick on the size bit for the select. Also, it says the options needs to be output (which seems like a really poor name to me). Like this:

    <select name="location" size="{$choice_values|@count}">
        {html_options values=$choice_values output=$choice_set selected=$choice}
    </select>
    

    Update: Based on Gerald’s excellent point in the comments.

    You could use the options template value if you instead defined an associative array instead of separate arrays. So this would also work:

    ======PHP =========

    $choices = array(100 => "A, 150 => "B", 200 => "C", 250 => "D", 300 => "E", 350 => "F");
    $choice=250;
    

    =====SMARTY=========

    <select name="location">
        {html_options options=$choices selected=$choice}
    </select>
    

    Also, I frequently forgot to $smarty->assign my variables, especially when I was prototyping or changing something. You’re probably smarter than me, in that regard, but it’s worth double checking.

    Sorry for my oversight, it’s been a while since I used smarty.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to display a dropdown list of users in my view. Here is
I'm trying to get a list of values to display upon a selection from
I am trying to create a dropdown list to display all the value in
I am trying to display all possible values for a sub-property. Below I am
With Shopify I am trying to alter my product template to display a dropdown
I am trying to concatenate two fields from a list to display in a
I'm trying to create a custom search but getting stuck. What I want is
I'm trying to find a dropdown-style list for images I can use in a
I am trying to make the drop down menu lists display inline(horizontally) but end
I'm trying to add a dropdown list to my Hotel view - index.cshtml. The

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.