Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How to create a drop down selection menu


spooks

Recommended Posts

Hi, I got this from Google's own SEO starter guide pages. They aren't saying they wont pick up these but they say these should be avoided as not all search engines will discover these, reducing your potential chances of being found

 

 

Ok , I had'nt seen that, but as the major search engines do follow them, those that don't are inconsequential.

 

I also feel its a big mistake to abandon a sites usability just to pander to the engines, after all, their not going to buy anything!! smile.gif

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

  • 1 month later...
  • Replies 75
  • Created
  • Last Reply

I can't seem to find a direct answer for my question and I thought this topic might be the place to find help. I want to add a color bar beside the drop down attribute included with osc V2.2 RC2. If you will look at my site url="http://www.crossgww.com"]My link[/url]and look at a candle category you will see the drop down attribute "color". This attribute tells what the color is but I want to but a circle of the color beside the actual word. For instance when the customer drops to the color "blue" it will show the color in word but also have an example of the color in a circle beside the word. I hope I am explaining this right so you can understand. I think it would make my site a better osc site for my customers.

 

Thanks for help

Link to comment
Share on other sites

  • 2 weeks later...

Great topic Sam!

 

Here's a tricky question...

 

Is it possible to customize the look of a drop-down menu?

Such as a background image.

 

I have searched the web and it sounds like a difficult process, almost impossible for the osC manufacturers search box.

 

Any help, ideas or suggestions would be greatly appreciated.

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

styleing form elements with css

Is it possible to customize the look of a drop-down menu?

 

 

You can specify the style for form elements in the css ie:

 

form {

border: 1px solid #000000;

padding: 8px;

background-color: #ffffff;

}

 

input {

background-color: #000000;

}

 

select {

background-color: #ffffff;

color: #000000;

}

 

textarea {

background-color: #ffffff;

color: #000000;

}

 

you can also add a style to individual form elements, ie

 

tep_draw_pull_down_menu('select_category', $category_array, $selected_cat, 'class="smallText"');

 

 

 

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Thanks for the reply Sam wink.gif

 

So far no matter what I have tried the drop-down select list menu still creates it's default/standard rectangle with the down arrow.

 

Although the background image "tries" to show through it just doesn't replace the default.

 

All other aspects change according to the CSS styles, such as color, fonts etc.

 

I'll keep playing around and searching!

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

  • 2 weeks later...

Hello, everyone.

 

I have been toying around with drop down menus for osCommerce for quite a few hours, and I can't seem to pass some values well.

 

Basically I have a file called stats.php . It has this line:

			<td class="main"><?php echo 'Enter month: <br>' . tep_draw_pull_down_menu('month1', $month_array, date('n'));?></td></tr>
			<tr><td class="main"><?php echo 'Enter year: <br>' . tep_draw_pull_down_menu('year1', $year_array, date('Y'));?></td></tr>
			<tr><td align="left"><?php echo '<br>' . tep_draw_form('view_stats', FILENAME_STATS, 'action=view_products&month=' . $month1 . '&year=' . $year1) . tep_draw_input_field('submit','Submit','',false,'submit'); ?>

 

What above code does is there are 2 drop downs (one for Month, one for Year) that have been populated with the correct values. There's also a SUBMIT button that's meant to redirect the site to something like "stats.php?action=view_stats&month=1&year=2010" . But I can't seem to "pass" the contents of the indexes/values of the drop downs. Please help me with this matter, thank you!

Link to comment
Share on other sites

It don't work outside a form!!

 

 

 

drop_downs must always be part of a form
wink.gif

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

UPDATE:

 

Somehow, I came up with the above code that gives the URL that I need (stats.php?action=view_stats&month=1&year=0):

				<td class="main"><?php echo 'Enter month: <br>' . tep_draw_form('choose_date', FILENAME_STATS,'','get') . tep_draw_hidden_field('action','view_stats') . tep_draw_pull_down_menu('month', $month_array, date('n'));?></td></tr>
			<tr><td class="main"><?php echo 'Enter year: <br>' . tep_draw_pull_down_menu('year', $year_array, date('Y'));?></td></form></tr>
			<tr><td align="left"><br><input title="View" name="submit" type="submit" value="Go" /></td></tr>

 

However, when I press the submit button (with label Go), nothing happens (that's probably because I ended the form before creating a new input. But when I put the </form> after the last input, I end up getting an additional parameter being passed after year=0 (the additional parameter is submit=Go, which is the name and the value of the input on the last part). How do I exclude the button from the creation of the whole URL? Thanks.

Link to comment
Share on other sites

 

 

 

you don't have to give a title or name, but if u don't process the param why do you care?

 

PS you must use tep_href_link within your form action, as detailed here already.

 

 

PPS please use 'reply' instead of 'add reply', threads full of new posts are hard to follow.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Hello Spooks I am relatively new to OSC so bear with me ... You wrote this post about Creating a drop down for attributes for OSC2.0 right here

http://www.oscommerce.com/forums/topic/342527-how-to-create-a-drop-down-selection-menu/

 

Will this work in 3.0 as well ? I am new to OSC and was brought in at the end of a project so I am reading and absorbing all I can as fast as possible I have some knowledge of php though ... I also have human resources that will supply and write and help with coding ... so I am just making sure I am going into the right direction.

 

The drop down will pass attributes to us about the order and is pretty simple usually 3 or 4 choices for about 10 or so products.

 

Again I want to make sure my work around is the most up to date for our version of osc .... so I guess I am asking does this module work in osc3. or is it maybe written into the current version of osc3.0

 

Thanks

 

Ken

Link to comment
Share on other sites

 

 

 

Due to the current states of v3 I have not examined the methods used within in any detail, the basic techniques for this will certainly still apply there.

 

 

Where other methods are required I'm sure anyone working with v3 could make the changes, though they would need to consider the likely changes to v3 on the next release.

 

 

If u have spare resources I'm sure its easier for u to research this than me.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

People often ask how to create a drop down selection menu for some item, they often seem to struggle coming up with some weird coding or attempt with pure html.

 

osC includes a function tep_draw_pull_down_menu which I will use, this removes much of the coding but requires a correctly formatted multi-dimensional

array, this is the achilles heel for many, preventing them using the function.

 

The parameters for tep_draw_pull_down_menu are ($name, $values, $default = '', $parameters = '', $required = false)

 

$name is the id for the field

$values is the array containing the selection data

$default is the default value selected

$parameters optional styling params

$required adds the defined TEXT_FIELD_REQUIRED text if true

 

For this example I will use code I created for a links categories pull down menu for my reciprocal links contrib.

 

 

Step one: create array & put default values

 

//category drop-down
 $category_array = array();
 $category_array[0] = array('id' => '0', 'text' => 'Please Select');

 

Step two: read data from dBASE for use in array

 

$category_query = tep_db_query("select category_id, category_name from links_categories where status = 1 order by sort_order, category_name");

 

Step three: loop through the data, placing it into the selection array ($category_array)

 

 while ($category_values = tep_db_fetch_array($category_query)) {
$category_array[] = array('id' => $category_values['category_id'], 'text' => $category_values['category_name']);
   }

 

Note the use of 'id' & 'text', 'id' contains the values returned on selection, 'text' is what's displayed by the drop down (these can be the same).

Remember this array has its own index, it is not indexed by 'id'.

 

Step Four: Output the drop down!!

 

<td align="right" width="100%"><?php echo tep_draw_form('category', tep_href_link('links.php', 'action=catsel'), 'get').'Links Category: ' . 
tep_draw_pull_down_menu('select_category', $category_array, $selected_cat, 'onchange="this.form.submit();" rel="nofollow"'); ?>
<noscript><input title="View" name="" type="submit" value="Go" /></noscript></form></td>

 

In this case the drop down is within its own form (drop_downs must always be part of a form), if you are using this as part of a bigger form you can

remove the form elements.

 

Note the use of tep_href_link in the form action, this is critical.

 

Links Category: is the displayed text adjacent the drop.

'select_category' is the field id.

$category_array we created above.

$selected_cat has the currently selected category (so that shows pre-selected in the drop (the default))

'onchange="this.form.submit();"' a parameter, in this case a bit of JavaScript to accept input as soon as change made (just an option).

rel="nofollow" often useful to prevent issues with google (duplicate content) this will prevent validation though, use a canonical tag if that's an

issue (just an option).

<noscript><input title="View" name="" type="submit" value="Go" /></noscript> provide a submit button if scripts are off (just an option)

 

Finally you must process the data at the receiving page, IE

 

$selected_cat = ($_GET['select_category'] > 0 ? $_GET['select_category'] : false);

 

this can be the same page if that's where your form action points.

 

ADVANCED OPTIONS

 

You may wish to access the data in the selection array separately, this will be an issue as the array has its own index, so placing the same data in a second

array at the same time you create the selection array is the answer, IE within the while loop add:

 

$categories[$category_values['category_id']] = $category_values['category_name'];

 

You can now get any category by its id with

echo $categories[$id];

 

I think I`ve covered it all there, no doubt issue will arrise though.

 

Hi,

 

I have a question for you sir. I want to create something similar to what you discussed. Basically I have my shopping cart link around my shopping cart area. When you click it it goes to the shopping cart which is fine and everything is good. Its a veyr basic text link with a cart image beside it. But here is what I think you know much about and I don't (since I'm not a programmer) I want to write a code that as I hover over the text a dropdown menu box appears, similar to your drop down menu. But instead of being a menu its a box an displays the products currently in the shopping cart as an array similar to "new to the store" infobox or other. Basiclaly with an image of the product on the left, name to the right of that and price below the name. followed by the next product and so on up to lets say 5 products. Meaning if I had 10 different products in my array it would show only 5 from the top or whatever. Do you think its possible you can help me write something like that?

 

Thank you,

AE

Thank you in advance,

AE

Link to comment
Share on other sites

Hi,

 

I have a question for you sir. I want to create something similar to what you discussed. Basically I have my shopping cart link around my shopping cart area. When you click it it goes to the shopping cart which is fine and everything is good. Its a veyr basic text link with a cart image beside it. But here is what I think you know much about and I don't (since I'm not a programmer) I want to write a code that as I hover over the text a dropdown menu box appears, similar to your drop down menu. But instead of being a menu its a box an displays the products currently in the shopping cart as an array similar to "new to the store" infobox or other. Basiclaly with an image of the product on the left, name to the right of that and price below the name. followed by the next product and so on up to lets say 5 products. Meaning if I had 10 different products in my array it would show only 5 from the top or whatever. Do you think its possible you can help me write something like that?

 

Thank you,

AE

 

This is not for menus

 

This forum is not here to provide a free coding service, if you write some code & have trouble, then ask, but if you want code written for you, hire a coder.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Hello all there,

 

A newbie here. Is there any chance that the dropdown menu in the admin/orders.php which handles the order statuses could be translated to a radio buttons? So if anyone process the orders, you can just hit the radio button (with pending, processing or shipped) will be displayed.

 

-Tj

Link to comment
Share on other sites

Hello all there,

 

A newbie here. Is there any chance that the dropdown menu in the admin/orders.php which handles the order statuses could be translated to a radio buttons? So if anyone process the orders, you can just hit the radio button (with pending, processing or shipped) will be displayed.

 

-Tj

 

 

If your wanting to write some code, look at the existing & see what you can do yourself, post your issues if you have problems. wink.gif

 

If your expecting someone else to write some code for you for free, your expecting too much from the forum!! ohmy.gif

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

  • 2 weeks later...

I am trying to get oscommerce to do something similiar to this site's drop down menus for each product. I have looked through several conreibutions, and not finding anything close that is working, or still be supported.

 

http://www.oemheaters.com/product/tabid/60/productid/86/sename/heavy-extra-heavy-duty-drumpail-heaters/default.aspx

 

I know this site was done in asp. I was thinking if a drop down menu for the main product would call the items from a category, with an option to add how many items, and add to cart button would be good. Then I can use the category hide contribution?

 

I may be overlooking something else that would work, so any advice would be greatly appreciated.

 

Thank you.

Link to comment
Share on other sites

  • 1 month later...

 

 

 

Your looking at something quite different, this thread is about standard osC drop down's, like the maunufacturer or atribute selections, your talking of menu's, the menu u link to is actually badly done with javascript, but could easily be done with css, look for css menu contribs.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

  • 1 month later...

Question --

 

How would I go about adding an if statement to a drop down?

 

Default Selected option -- Please Select

Option 1 -- Yes

Option 2 -- No

 

If user selects yes, add a new label and text box underneath the current label and drop menu.

 

If user selects no, do nothing.

 

My current array looks like:

 

     <?php 
       $some_array = array();
       $some_array[0] = array('id' => '0', 'text' => 'Please Select');
       $some_array[1] = array('id' => '1', 'text' => 'Yes');
       $some_array[2] = array('id' => '2', 'text' => 'No');
     ?>

 

Not sure how to go with this if statement though.

 

Tags: if statement php array drop menu pull down tep_draw_pull_down_menu

Link to comment
Share on other sites

How would I go about adding an if statement to a drop down?

 

 

If user selects yes, add a new label and text box underneath the current label and drop menu.

 

If user selects no, do nothing.

 

 

 

I think your saying u want to update the page content dynamically without refreshing the page, to do that you have to use ajax (ie javascript) look at those methods, but remember to allow for visitors that have scripts off.

 

To change any page coontent with pure php you have to reload the page, ie set and compare a var.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

  • 1 month later...

This is the standard method used by osC for all pull downs, so to see an example just look at any pull down from a official distribution (ie manufacturers on home page etc).

 

Please note, often template writers have no clue how this is supposed to work, so pull downs in templates are often severely hacked (and bugged), so ignore them.

Hi

I am new to this forum, and relatively new to OS Commerce. I've taken on this project to create my ecommerce website, and decided to go with OS Commerce. I've been reading various sources to educate myself on how to tweak OS Commerce. To speed up the design of my site, i decided to purchase a template. I've been able to tweek it for the most part. However, I am now stuck. In the original OS Commerce v2.2 RC2 distribution, a drop down box for choosing the manufacturer shows up in the subcategory (DVD Movies -> Action (9). My template does not show this drop down menu, and it's been driving me crazy trying to find where this may be in the original distribution so that I can try and recreate it in my template. Any help pointing me to this direction would be appreciated. I will post an image to show the drop down menu I am referring to... on second thought I cant seem to upload an image file here... Thanks,

Link to comment
Share on other sites

Hi

I am new to this forum, and relatively new to OS Commerce. I've taken on this project to create my ecommerce website, and decided to go with OS Commerce. I've been reading various sources to educate myself on how to tweak OS Commerce. To speed up the design of my site, i decided to purchase a template. I've been able to tweek it for the most part. However, I am now stuck. In the original OS Commerce v2.2 RC2 distribution, a drop down box for choosing the manufacturer shows up in the subcategory (DVD Movies -> Action (9). My template does not show this drop down menu, and it's been driving me crazy trying to find where this may be in the original distribution so that I can try and recreate it in my template. Any help pointing me to this direction would be appreciated. I will post an image to show the drop down menu I am referring to... on second thought I cant seem to upload an image file here... Thanks,

Looks like I found the culprit. It's in the index.php file under //optional product list filter. Apparently mine was enclosed with this - /* */

 

Now that I've removed the, my template format is out of whack... : (

Link to comment
Share on other sites

  • 1 month later...

Hello,

 

This drop down works very well, but I have one question. How do you set the maximum category value, ie. in the admin section of OSc, you can set the maximum value for the number of characters that will be displayed in the manufacturer's box. Can this be done with the category drop down? I know I am missing something here, as this doesn't seem too complicated. Any help is greatly appreciated.

 

Thanks,

 

B.

Link to comment
Share on other sites

  • 1 year later...

Hi Sam and al the ppl out here,

 

is it possible to make a dropdown button for customers to select a pickup day in the shipping section during checkout?

so custumor select cash on pickup and come to shop on (dropdown menu) monday thuesday etc. etc.

i will be verry happy if i would have that option.

 

greetz Edwin

Link to comment
Share on other sites

Hi,

 

I have read your drop down selection menu. www.winningcolours.co.uk want an option where when the customer makes a selection it changes the image as they go along so they can see what they are purchasing. The site has been setup using OS commerce. Do you have any ideas how I do this?

 

Regards

 

Richard

 

People often ask how to create a drop down selection menu for some item, they often seem to struggle coming up with some weird coding or attempt with pure html.

 

osC includes a function tep_draw_pull_down_menu which I will use, this removes much of the coding but requires a correctly formatted multi-dimensional

array, this is the achilles heel for many, preventing them using the function.

 

The parameters for tep_draw_pull_down_menu are ($name, $values, $default = '', $parameters = '', $required = false)

 

$name is the id for the field

$values is the array containing the selection data

$default is the default value selected

$parameters optional styling params

$required adds the defined TEXT_FIELD_REQUIRED text if true

 

For this example I will use code I created for a links categories pull down menu for my reciprocal links contrib.

 

 

Step one: create array & put default values

 

//category drop-down
 $category_array = array();
 $category_array[0] = array('id' => '0', 'text' => 'Please Select');

 

Step two: read data from dBASE for use in array

 

$category_query = tep_db_query("select category_id, category_name from links_categories where status = 1 order by sort_order, category_name");

 

Step three: loop through the data, placing it into the selection array ($category_array)

 

 while ($category_values = tep_db_fetch_array($category_query)) {
$category_array[] = array('id' => $category_values['category_id'], 'text' => $category_values['category_name']);
   }

 

Note the use of 'id' & 'text', 'id' contains the values returned on selection, 'text' is what's displayed by the drop down (these can be the same).

Remember this array has its own index, it is not indexed by 'id'.

 

Step Four: Output the drop down!!

 

<td align="right" width="100%"><?php echo tep_draw_form('category', tep_href_link('links.php', 'action=catsel'), 'get').'Links Category: ' . 
tep_draw_pull_down_menu('select_category', $category_array, $selected_cat, 'onchange="this.form.submit();" rel="nofollow"'); ?>
<noscript><input title="View" name="" type="submit" value="Go" /></noscript></form></td>

 

In this case the drop down is within its own form (drop_downs must always be part of a form), if you are using this as part of a bigger form you can

remove the form elements.

 

Note the use of tep_href_link in the form action, this is critical.

 

Links Category: is the displayed text adjacent the drop.

'select_category' is the field id.

$category_array we created above.

$selected_cat has the currently selected category (so that shows pre-selected in the drop (the default))

'onchange="this.form.submit();"' a parameter, in this case a bit of JavaScript to accept input as soon as change made (just an option).

rel="nofollow" often useful to prevent issues with google (duplicate content) this will prevent validation though, use a canonical tag if that's an

issue (just an option).

<noscript><input title="View" name="" type="submit" value="Go" /></noscript> provide a submit button if scripts are off (just an option)

 

Finally you must process the data at the receiving page, IE

 

$selected_cat = ($_GET['select_category'] > 0 ? $_GET['select_category'] : false);

 

this can be the same page if that's where your form action points.

 

ADVANCED OPTIONS

 

You may wish to access the data in the selection array separately, this will be an issue as the array has its own index, so placing the same data in a second

array at the same time you create the selection array is the answer, IE within the while loop add:

 

$categories[$category_values['category_id']] = $category_values['category_name'];

 

You can now get any category by its id with

echo $categories[$id];

 

I think I`ve covered it all there, no doubt issue will arrise though.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...