I am using the following function:
$.each($('.update-grid'), function (i, e) {
var ID = e.id.replace('modal', 'input');
$("#" + ID).val(e.value);
});
to get a value that’s just been entered into an input field such as this after form submission. The requirement is to take this user enterered value and put it in another field. For example transfer the value entered into #modal-title into the field #input-title.
<input id="modal_Order_1" class="update-grid full-width" type="text"
value="337" name="Content.Order" >
However the “e.value” gives me the value 337 and not the value that the user entered just before the form was submitted.
Is there a way I can get the NEW value entered?
Update:
This seems to work:
$('.update-grid')
.each(function () {
var id = this.id.replace('modal', '');
$('#input' + id).val(this.value)
})
You’re using the
.eachfunction incorrectly. You will need to rely upon the.changeevent, this means it wil be triggered after a change has been input (and the field loses focus).So given your code, I would say: