Wednesday 21 August 2013

Get the value from a select box and display their value.Using jQuery


Display select box selected value using jQuery......
<html lang="en">
 <head>
   <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
 </head>
  <body>
  <p></p>
 <select id="kc">
   <option>knowledge</option>
   <option>cornor</option>
   <option>knowledgecornor</option>
   <option>srinu chilukuri</option>
 </select>
 <script>
   function displayVals() {
   var singleValues = $("#kc").val();
   $("p").html("<b>value:</b> " +
   singleValues );
   }
   $("select").change(displayVals);
   displayVals();
 </script>
 </body>
</html>
Demo: