Published on: 15 February, 2017

How to get selected combo box value using JQuery and Javascript

Posted by andy | 499 views 0 likes 0 favourites 0 comments
Tumblr Digg Google Plus

In the past article, you have already learnt how to get a value from a check box using a JQuery and Javascript. You can check the article in here. Well in addition to that, I will show you how to get a value and text from a combo box or select dropdown input.

Let says we have the following combo box inputs with the following text and values.

We will create 4 different functions to get text and value of a combo box using Javascript and JQuery.

//Function scripts to get value/text using JQuery or Javascript
<script text="tetxt/javascript">
	function getTextUsingJavascript(){
		var cbo = document.getElementById("cboItem");
		alert("The selected text is " + cbo.options[cbo.selectedIndex].text);
	function getValueUsingJavascript(){
		var cbo = document.getElementById("cboItem");
		alert("The selected value is " + cbo.options[cbo.selectedIndex].value);
	function getTextUsingJQuery(){
		alert("The selected text is " + $("#cboItem :selected").text());
	function getValueUsingJQuery(){
		alert("The selected value is " + $("#cboItem").val());

<select id="cboItem">
	<option value=''>Select Programming Language</option>
	<option value='1'>Javascript</option>
	<option value='2'>JQuery</option>
	<option value='3'>C#</option>
	<option value='4'>PHP</option>

<button id="btnGetTextJavascript" onclick="getTextUsingJavascript()">Get Text Using Javascript</button> 
<button id="btnGetValueJavascript" onclick="getValueUsingJavascript()">Get Value Using Javascript</button>
<button id="btnGetTextJQuery" onclick="getTextUsingJQuery()">Get Text Using JQuery</button>
<button id="btnGetValueJQuery" onclick="getValueUsingJQuery()">Get Value Using JQuery</button>

Pretty easy right? Hopefully it helps for newbie that just start learning JQuery and Javascript programming.


There are no comments available.

Write Comment
0 characters entered. Maximum characters allowed are 1000 characters.
Related Articles
Published on: 22 March, 2016
In this tutorial, you will learn how to create a category menu list using css and JQuery framework. You will also learn on how to automatically place an arrow into the LI element if it founds there is a sub menu list. The placement of the arrow is done via JQuery, this includes binding the event onclick on the LI element as well to expand and collapse the sub menu list.
Published on: 08 March, 2016
Completely new to JQuery script? Don't worry, you are not alone. We have summarize a list of tips for newbie to learn JQuery faster. The best way to strength your JQuery skills is by testing our tips directly in your html files and run it.
Published on: 02 May, 2014
Are you lazy to google the quick jquery code snippet for your website? Look no further, we have included a quick summary list of JQuery code to help you faster coding to save your time. Starting from how to check if an object is visible or how to tick a check box programmatically using JQuery.
Related Tutorials
Published on: 25 January, 2016
So what actually an event? An event can be considered as a result of an action triggered by a process which can be a process clicking of a user or when a page is loading.
Published on: 20 December, 2015
Learn how easily to manipulate DOM element selection using JQuery. One of the cool feature from JQuery is the DOM selector. In javascript, when you want to reference an object, you can refer the object either based on ID or class name of the object by using the built in function such as getElementById or getElementByTagName or getElementsByClassName.
Published on: 15 December, 2015
Getting started by writing your first JQuery code. Learn how to create it from scratch and apply it on your site. The best way to start your first JQuery function is after the browser has completedly loaded the page content. There are two short methods to do so.
Published on: 13 December, 2015
Learn what is the JQuery framework is and why many web developers and designers love to this framework.