Category Archives: how to handle jquery select box onchange event

jQuery onchange-onfocus select box

If you need to bind a function to be called when a user selects an option from a select box using jQuery, you’ve come to the right place.

There are several different ways to skin this cat, but basically here is what we are going to do:

1. Bind a change event listener to the select box itself
2. When the box is changed, call a function that detects and retrieves the selected value

Here’s the code:
Sample 1

<script type="text/javascript">
          var selected = $("#selectboxid option:selected");
	    if(selected.val() == 0 ){
	        alert('Select Module');	
	        do something;

Sample 2

script type="javascript">
$(document).ready(function(){     //$(function(){
var selectedValue = $(this).find(":selected").val();
alert('The selected value is'+selectedValue);

Similar Links:
Jquery tutorial Site
Select Box on Change
onchange select box