Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

categories in a drop down menu


Guest

Recommended Posts

Posted

Hi, I'll like to know how to put the categories from the left column inside a drop down menu instead of the way it's being displayed right now. Also, I'd like to know if its possible to have that drop down menu in other places such as the index.php or the header.php.

 

Thanks in advance.

 

Fabian.

Posted

You could do it.. You would need to populate the value of each selection with the url of the category such as:

<form name="categories" method=get>

<select name="anyname" onChange="redirect()">

<option value="http://mywebsite/catalog/index.php?cID=1">Category 1</option>

 

Then some javascript that would redirect upon change;

 

<script type="text/JavaScript">

<!--

function redirect(){

var URL = document.resources.res.options[document.resources.res.selectedIndex].value;

top.location.href = URL;

}

//-->

</script>

 

Or you could add a submit button if you did not want the onchange event. Then you would need to add a function on the other end..

 

Good luck..

Lloyd

Posted
You could do it.. You would need to populate the value of each selection with the url of the category such as:

<form name="categories" method=get>

<select name="anyname" onChange="redirect()">

<option value="http://mywebsite/catalog/index.php?cID=1">Category 1</option>

 

Then some javascript that would redirect upon change;

 

<script type="text/JavaScript">

<!--

function redirect(){

var URL = document.resources.res.options[document.resources.res.selectedIndex].value;

top.location.href = URL;

}

//-->

</script>

 

Or you could add a submit button if you did not want the onchange event. Then you would need to add a function on the other end..

 

Good luck..

 

Thank you Lloyd, but I have another question;

 

As long as I have to type myself the category's name in the drop down menu, it won't be linked to the database, so every time a change or add a new category it won't appear in the menu.

 

Q: Is there any possibility where I can have that code linked to the database so I don't have to change it any more?

 

Thanks Fabian.

Archived

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

×
×
  • Create New...