Grab the RSS feed

Get the dropdown value using Jquery

Today I am going to tell you how to get the dropdown value when the user clicks on it. It sometimes very much useful to get the value and stored it on database.

For example you may use the time zone or anything.At that time it provides more helpful to you.

Even this is going to be small thing it helps a lot.

Here the HTML code is displayed…

;">< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > 
< html xmlns="http://www.w3.org/1999/xhtml" > 
< head > 
< meta http-equiv="Content-Type" content="text/html; charset=utf-8" / > 
< title > Untitled Document< /title > 
< script type="text/javascript" src="jquery/jquery.js" > < /script > 
< script type="text/javascript" src="jquery/getdropdownvalue.js" > < /script > 
< /head > 

< body > 
< select name="getdropdown" id="getdropdown" > 
< option value="1" > Trial  1< /option > 
< option value="2" > Trial  2< /option > 
< option value="2" > Trial  3< /option > 
< option value="2" > Trial  4< /option > 
< option value="2" > Trial  5< /option > 
< option value="2" > Trial  6< /option > 
< /select > 
< /body > 
< /html > 

The Jquery will be coded below as…
$(document).ready(function(){

$("#getdropdown").change(function() {
var trial=$("#getdropdown option:selected").text();
alert(trial);
});

});


Here getdropdown is the ID of dropdown box

You can put val() instead of text() you get the dropdown value

0 comments:

  •  
    Real Time Web Analytics