Dropdown box help

Ask the community for help and support.
Post Reply
maryjane
Posts: 18
Joined: Wed Apr 13, 2022 5:39 am
Has thanked: 9 times
Been thanked: 2 times

Dropdown box help

Post 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.
heatherbell
VIP Member
VIP Member
Posts: 1996
Joined: Mon Oct 07, 2019 4:39 am
Has thanked: 26 times
Been thanked: 175 times

Re: Dropdown box help

Post 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
maryjane
Posts: 18
Joined: Wed Apr 13, 2022 5:39 am
Has thanked: 9 times
Been thanked: 2 times

Re: Dropdown box help

Post 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
heatherbell
VIP Member
VIP Member
Posts: 1996
Joined: Mon Oct 07, 2019 4:39 am
Has thanked: 26 times
Been thanked: 175 times

Re: Dropdown box help

Post 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.
14Steve14
VIP Member
VIP Member
Posts: 549
Joined: Fri Oct 25, 2019 7:01 pm
Has thanked: 8 times
Been thanked: 49 times

Re: Dropdown box help

Post 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.
burt
Lead Developer
Lead Developer
Posts: 2423
Joined: Tue Oct 29, 2019 9:37 am
Has thanked: 49 times
Been thanked: 137 times

Re: Dropdown box help

Post 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>
Gamechanger Addon: Queued Emails, try before you buy.
Post Reply