Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Default Text Selection for Category Pull Down Menu


Guest

Recommended Posts

I'm adding a pull down category menu to my header by modifying code provided by " All Categories Dropdown by Weirdlab".

 

Presently, the "default" selection is the first item in my category list. I would like to change the selection and have it default to the "PULL_DOWN_DEFAULT" contained in the \includes\languages\english.php file (says "Please Select).

 

I have no idea how to make the default selection of the pull down menu "PULL_DOWN_DEFAULT". Any help would be appreciated!

 

Here is my code:

 

  
$cat_choose = '';
$categories_array = tep_get_categories($cat_choose);

echo tep_draw_form('quick_find', tep_href_link(FILENAME_DEFAULT, '', 
'NONSSL', false), 'get') .  tep_draw_pull_down_menu('cPath', $categories_array,'',
'onChange="this.form.submit();" style=""') . '</form>';

Link to comment
Share on other sites

I'm adding a pull down category menu to my header by modifying code provided by " All Categories Dropdown by Weirdlab".

 

Presently, the "default" selection is the first item in my category list. I would like to change the selection and have it default to the "PULL_DOWN_DEFAULT" contained in the \includes\languages\english.php file (says "Please Select).

 

I have no idea how to make the default selection of the pull down menu "PULL_DOWN_DEFAULT". Any help would be appreciated!

 

Here is my code:

 

  
$cat_choose = '';
$categories_array = tep_get_categories($cat_choose);

echo tep_draw_form('quick_find', tep_href_link(FILENAME_DEFAULT, '', 
'NONSSL', false), 'get') .  tep_draw_pull_down_menu('cPath', $categories_array,'',
'onChange="this.form.submit();" style=""') . '</form>';

 

You would need to add Please select as an option first

 

such as (added in bold)

 

$cat_choose = '';

$categories_array = tep_get_categories($cat_choose);

 

$categories_array[]=array('id'=>'Please Select','text'=>'Please Select');

 

echo tep_draw_form('quick_find', tep_href_link(FILENAME_DEFAULT, '',

'NONSSL', false), 'get') . tep_draw_pull_down_menu('cPath', $categories_array,PULL_DOWN_DEFAULT,

'onChange="this.form.submit();" style=""') . '</form>';

 

Not tested but I'm pretty sure that will work.

Link to comment
Share on other sites

Yes, the code works. "Please Select" is now the default option. However, I noticed in the pull down menu, it is the last option to select. In addition, when choosing a category, after the specified category page is loaded, the pull down menu defaults back to the "Please Select"

 

Is there a way to do the following:

 

1. The default text or id is the "first" choice on the pull down list instead of the last?

 

2. Ability to have the pull down reflect the category you are viewing and only show default text when no other category has been choosen?

 

I am trying to get the pull down menu to work like the one contained in the following code from: Category Box with Dropdown FixCategory Box with Dropdown Fix

 

$info_box_contents[] = array('form' => '<form action="' . tep_href_link(FILENAME_DEFAULT) . '" method="get">' . tep_hide_session_id(),
                              'align' => 'left',
                              'text'  => '<b>' . 'Go to..' . '<br>' . tep_draw_pull_down_menu('cPath', tep_get_paths(array(array('id' => '', 'text' => PULL_DOWN_DEFAULT))), $cPath, 'onchange="this.form.submit();"')
                             );
 new infoBox($info_box_contents);

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...