Im using .append() to print the value of an input field to a span. The form is AJAX so multiple values are inputted into the form therefore I want to print these multiple inputs. This works well, apart from the below IF statement isn't switching the string value of 'names', any ideas?
$("input").bind("keydown", function(event) {
var keycode = (event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode));
if (keycode == 13) {
var value = $(this).val();
var names = '';
if (names == '') {
names = value;
}
else {
names = value + ', ' + names '.';
}
$("span#name1").append(names);
return false;
} else {
return true;
}
}