I have a jsp page.
I have a numeric select list. Whose has some default value but that is dynamically generated.
I also have a text field.
I want the text field should be filled automatically exactly as the selected option from the select list. I am using jquery to do it.
But i see when the jsp page load, the select list is there with its default value but the text field is blank. text field getting filled with selected option only when i change the option. I want that when the page load the text field get also filled with the dynamically generated option as with the select list.
My code of jquery inside script tag is :
$(document).ready(function(){
$("#select_id").change(function() {
$("#textfield_id").val($("#select_id option:selected").text());
});});
Can any one suggest what should i do ?
1 Answer