Skip to content
WJunction - Webmaster Forum

Get Category ID from <select> menu?

Status
Not open for further replies.

Exel

Senior Member
2,074
2008
543
ZbIgD.png
 

4 comments

You can do this with jQuery something like this :
PHP:
<script type="text/javascript">
$(function () ) {
       $('#category_id').change(function(){
       var id = $(this).find(':selected')[0].id;
       $('#something').val(id);

       alert(id); // this is just for testing remove this :|
});
</script>

<input type="hidden" name="category_id_s" value="cars" id="something" />
etc..
 
Not sure why you would want to get the selected value to another html element.
You can get the same thing by adding name="category_id" attribute to the select tag. Value of category_id when submitted would be equal to the selected item's value
 
I have problem maybe like this...
you can see this thread
Code:
http://www.wjunction.com/92-development-area/159368-print-selected-value-list-menu-php.html
or here is full code
Code:
http://pastebin.com/5U5Xedp8
maybe this be helpful
 
Not sure why you would want to get the selected value to another html element.
You can get the same thing by adding name="category_id" attribute to the select tag. Value of category_id when submitted would be equal to the selected item's value

That worked, thanks soft.
 
Status
Not open for further replies.

About the author

E
Senior Member · Joined
I come from Uranus. Eating cookies.
2,074
Messages
543
Reactions
113
Points
Grow your business

Advertise on WJunction

Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.

  • Premium & Premium+ Sticky
  • Dedicated section banners
  • Site-wide banner advertising
Explore advertising options
Back
Top Bottom