Just set value to input store it in some temporary variable, append the value you want to store and set the value of input to this temporary variable eg.
<input id="user" type="text" name="user" class="form-control" />
<input id="user_id" type="hidden" name="user_id" value="" />
var oldValue = $("#user_id").val(); var arr = oldValue === "" ? [] : oldValue.split(','); arr.push(yardval); var newValue = arr.join(','); $("#user_id").val(newValue);