I am attempting to change the value of a text input based on the user selecting a value from a pulldown. I have got it working using the following,
$(document).ready(function() {
$(document).on("change", "#name", function() {
$("#firstname").val( this.value ); // this.value is enough for you
}).val( $('#firstname').val() ).change(); // for pre-selection trigger
});
Instead of .live() use .on() with jQuery 1.7+, because live() is deprecated.
Syntax of .on() for delegate event handling is:
$(StaticParent).on( eventName, target, handlerFunction );
Where, StaticParent means the non-dynamic parent container of target element on which you want to bind event.
So, for above case it would be better to use any static parent of #name instead of document.