copy/duplicate and concatenate values of multiple input boxes to one
I have input fields for street, city, state and zip and the fifth one that says complete address
Use the +
for Javascript concatenation:
$('#latlongaddress').val($('#street').val() + ' ' +
$('#city').val() + ', ' +
$('#state').val() + ' ' +
$('#zip').val() );
See the jsFiddle.
Just for fun:
$('#latlongaddress').val( $('#street,#city,#state,#zip').map(function(){
return $(this).val();
}).get().join(' ') );
eykanal's answer is better because it will run quicker and is easier to understand. Only actually use this for something like .val($('input')...