Page 1 of 1

Dropdown box help

Posted: Wed Apr 13, 2022 5:49 am
by maryjane
So am trying to learn and do somethings for myself and working on an addon for my shop. I want to know how I can do a dropdown with options 1,2,3 in it. I copied an example of store code with a dropdown but don't know how to add the options I want in it.

//$contents[] = ['text' => TEXT_INFO_OPTIONS . '<br>' . tep_draw_pull_down_menu('user_options', (1, 2, 3))];

I have a dropdown but no options in it. Please I need help with this.

Re: Dropdown box help

Posted: Wed Apr 13, 2022 5:58 am
by heatherbell
maryjane wrote: Wed Apr 13, 2022 5:49 am I have a dropdown but no options in it. Please I need help with this.
You don't say what store code you are using but maybe look at the Navbar Account module to see how it is done
https://github.com/CE-PhoenixCart/Phoen ... ccount.php

Re: Dropdown box help

Posted: Wed Apr 13, 2022 6:40 am
by maryjane
Am not sure about this link, I only wanted to populate numbers 1, 2, 3 as options in my dropdown. The link you passed me only gives dropdown for links and doesn't look like format of my example. Thanks you

Re: Dropdown box help

Posted: Wed Apr 13, 2022 7:01 am
by heatherbell
maryjane wrote: Wed Apr 13, 2022 6:40 amdoesn't look like format of my example.
https://github.com/CE-PhoenixCart/Phoen ... t.php#L147
shows the code that function is expecting so maybe the values should be a string.

Re: Dropdown box help

Posted: Wed Apr 13, 2022 10:56 am
by 14Steve14
maryjane wrote: Wed Apr 13, 2022 5:49 am So am trying to learn and do somethings for myself and working on an addon for my shop. I want to know how I can do a dropdown with options 1,2,3 in it. I copied an example of store code with a dropdown but don't know how to add the options I want in it.

//$contents[] = ['text' => TEXT_INFO_OPTIONS . '<br>' . tep_draw_pull_down_menu('user_options', (1, 2, 3))];

I have a dropdown but no options in it. Please I need help with this.
Depending on what you want the options to be, could you just use a text link to a language define or constant. Not a coder by the way. If options 1,2,3 are always going to be the same this may be one way of doing it.

Re: Dropdown box help

Posted: Thu Apr 21, 2022 9:26 am
by burt
The list of selections needs to be a multi-dimensional array in the format ID and TEXT, eg;

Code: Select all

tep_draw_pull_down_menu('user_options', [ 
  ['id' => 1, 'text' => 'one'], 
  ['id' => 2, 'text' => 'two']
]);
Will create the following output:

Code: Select all

<select name="user_options" class="form-control">
  <option value="1">one</option>
  <option value="2">two</option>
</select>