You can use jquery function.
<form name='add'>
<input type='text' name='stud_name' id="stud_name" value=""/>
Age: <select name='age' id="age">
<option value='1' stud_name='sre'>23</option>
<option value='2' stud_name='sam'>24</option>
<option value='5' stud_name='john'>25</option>
</select>
<input type='submit' name='submit'/>
</form>
jquery code :
<script type="text/javascript" src="jquery.js"></script>
<script>
$(function() {
$("#age").change(function(){
var option = $('option:selected', this).attr('stud_name');
$('#stud_name').val(option);
});
});
</script>