0

I'm new to php and I've encountered a problem on school project. The question I have is, as the question suggested, to pass variable to url when a link is click. My problem is I have a drop down menu, which displays a category of menu products, e.g. food, drinks, desert. And when I click on the food category, the url will display :

 http://localhost/products.php?menu=food

and if I click on the drinks category the url will display:

http://localhost/products.php?menu=drinks 
4b0
  • 21,981
  • 30
  • 95
  • 142
Azvier
  • 33
  • 11

1 Answers1

1
 <select name="color" id="dropdown">
   <option value="food"> food </option>
<option value="drink"> drink</option>
</select>

Jquery for get the dropdown value

$('#dropdown').change(function() {
   var menu = $(this).val();
    window.location.href = 'your_url.php?menu='+menu;
});
prakash tank
  • 1,269
  • 1
  • 9
  • 15
  • `$('.dropdown dropdown-menu a').click(function(){ var menu = $(this).attr('value'); window.location.href = 'your_url.php?menu='+menu; });` – Pavan Kumar Manda Dec 26 '16 at 09:33