Getting selected option value from Listbox

On Select of listbox, text box value ( data ) will change

Student Name
Details
<script>
$(document).ready(function() {
$("#student").change(function(){ // change function of listbox
var sel = $("#student").val(); // reading listbox selection
$("#t1").attr('value',sel); // keeping in a text box
});
});
</script>