Jump to content



Photo
* * * * * 3 votes

How to create a drop down selection menu


This topic has been archived. This means that you cannot reply to this topic.
75 replies to this topic

#21   spooks

spooks
  • Members
  • 7,017 posts

Posted 16 October 2009 - 16:29

Personally Im not overkeen on using drop down menu's as search engines can overlook the content in them, adversely affecting your ranking


[img]http://forums.oscommerce.com/public/style_emoticons/default/huh.gif[/img]

Would you care to say what search engines you believe have this issue, it certainly is not one with google, infact I have given details here on what to do to stop google following links in the drop.
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.

#22   blurredreality

blurredreality
  • Members
  • 28 posts

Posted 02 November 2009 - 16:37

Hello there - warning - relative newbie!

I like the sound of this, although can I have some clarification on how the drop down functions, and how to set it up also.

Basically, I am looking to create a one page order form. I sell pictures, the price of which varies depending on the picture style, the number of faces included in the artwork, the media of the print, and the size of the print. I have come up with a potential way of sorting this, by having each picture style (I have 7) as a product (with attributes for number of faces), and having media types as products also (with sizes as attributes).

I am looking to have all this information displayed on one page. Would this drop down list allow users to select a product, and then have it so the 'add to cart button' updates based on this selection? Would this work for multiple products on one page (so they can select style from one drop down menu, number of faces from another, media from another, and size from another)?

If so, I am looking to use it. However, excuse my ignorance, but where do the first 3 codes which you list get placed? Is it in a new file? Or the one displaying the drop down? And is there anything I need to put before or after the code?

I hope I have been clear here, I appreciate any help - thanks!

Edited by blurredreality, 02 November 2009 - 16:42.


#23   spooks

spooks
  • Members
  • 7,017 posts

Posted 02 November 2009 - 17:09

Hello there - warning - relative newbie!

I like the sound of this, although can I have some clarification on how the drop down functions, and how to set it up also.

Basically, I am looking to create a one page order form. I sell pictures, the price of which varies depending on the picture style, the number of faces included in the artwork, the media of the print, and the size of the print. I have come up with a potential way of sorting this, by having each picture style (I have 7) as a product (with attributes for number of faces), and having media types as products also (with sizes as attributes).

I am looking to have all this information displayed on one page. Would this drop down list allow users to select a product, and then have it so the 'add to cart button' updates based on this selection? Would this work for multiple products on one page (so they can select style from one drop down menu, number of faces from another, media from another, and size from another)?

If so, I am looking to use it. However, excuse my ignorance, but where do the first 3 codes which you list get placed? Is it in a new file? Or the one displaying the drop down? And is there anything I need to put before or after the code?

I hope I have been clear here, I appreciate any help - thanks!



Not sure its whatr u mean, but it appears your saying u want visitors to buy 2 products to buy one, if so, not a good plan, see if u can work it through categories, then product then attributes, remeber a product can be in multiple categories & have multiple attributes.

but where do the first 3 codes which you list get placed



again I'm not sure what you mean, all the data fo the drops are placed in arrays in memory, they are'nt stored anywhere, except that u can pull that data for them from ther dbase, or hard code it.
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.

#24   blurredreality

blurredreality
  • Members
  • 28 posts

Posted 02 November 2009 - 17:31

Not sure its whatr u mean, but it appears your saying u want visitors to buy 2 products to buy one, if so, not a good plan, see if u can work it through categories, then product then attributes, remeber a product can be in multiple categories & have multiple attributes.




again I'm not sure what you mean, all the data fo the drops are placed in arrays in memory, they are'nt stored anywhere, except that u can pull that data for them from ther dbase, or hard code it.



Hello, and thanks for the quick reply.

I was going to try to explain the general problems I am having in figuring out the logistics for how to sell on my site - but I figure that that would be taking this thread off-topic (and would be very needy and demanding of me).

--
In the time I was writing a response I have figured out a method I might use to try and get my site working. Sorry to have wasted your time!

I am simply going to try and reconfigure everything via attributes - essentially having 1 product with multiple attritbutes (e.g. style, number of faces, size e.t.c.)

#25   ironmon1

ironmon1
  • Members
  • 54 posts

Posted 04 November 2009 - 20:42

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


[img]http://forums.oscommerce.com/public/style_emoticons/default/huh.gif[/img]

Would you care to say what search engines you believe have this issue, it certainly is not one with google, infact I have given details here on what to do to stop google following links in the drop.



#26   spooks

spooks
  • Members
  • 7,017 posts

Posted 04 November 2009 - 21:09

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!! [img]http://forums.oscommerce.com/public/style_emoticons/default/smile.gif[/img]
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.

#27   cgww

cgww
  • Members
  • 5 posts

Posted 14 December 2009 - 19:49

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

#28   jhande

jhande
  • Members
  • 2,236 posts

Posted 23 December 2009 - 01:47

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 -

#29   spooks

spooks
  • Members
  • 7,017 posts

Posted 23 December 2009 - 22:11

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.

#30   jhande

jhande
  • Members
  • 2,236 posts

Posted 23 December 2009 - 23:04

Thanks for the reply Sam [img]http://forums.oscommerce.com/public/style_emoticons/default/wink.gif[/img]

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 -

#31   Winterburn

Winterburn
  • Members
  • 35 posts

Posted 03 January 2010 - 19:31

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!

#32   spooks

spooks
  • Members
  • 7,017 posts

Posted 03 January 2010 - 20:36

It don't work outside a form!!



drop_downs must always be part of a form

[img]http://forums.oscommerce.com/public/style_emoticons/default/wink.gif[/img]
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.

#33   Winterburn

Winterburn
  • Members
  • 35 posts

Posted 04 January 2010 - 04:38

Oh Ok. Now I get it.

So do I have to create a form for both dropdowns and my submit button as well? Or can I encapsulate them under one drop down?

And how do I exactly pass the index and/or value of a given drop down? Help!

Edited by Winterburn, 04 January 2010 - 04:47.


#34   Winterburn

Winterburn
  • Members
  • 35 posts

Posted 04 January 2010 - 06:07

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.

#35   spooks

spooks
  • Members
  • 7,017 posts

Posted 04 January 2010 - 11:59



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.

#36   I_am_Baldguy

I_am_Baldguy
  • Members
  • 11 posts

Posted 11 January 2010 - 18:12

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://forums.oscomm...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

#37   spooks

spooks
  • Members
  • 7,017 posts

Posted 11 January 2010 - 20:59



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.

#38   aelalfy1989

aelalfy1989
  • Members
  • 99 posts

Posted 13 January 2010 - 23:06

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

#39   spooks

spooks
  • Members
  • 7,017 posts

Posted 14 January 2010 - 12:06

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.

#40   tjc0ol

tjc0ol
  • Members
  • 4 posts

Posted 21 January 2010 - 06:57

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