Im having the following Function where user hits inputs new Key, the save into the DB., but the problem is im input are getting saved into db as 1,12,123,124,1245,12456...and so on? how can i input the value as a whole. ?
wo_input.oninput = function() {
if (wo_input.value) {
if (wo_input.value.length > 0) {
saveOnChange(wo_input.value, 'wo_number');
} else { }
} else { }
}
Save on Change Function
function saveOnChange(val, type) {
var diagnosis_id = $('#diagnosis_id').val();
console.log(val + " : " + type + " : " + diagnosis_id);
$.post('/diagnosis/saveOnChange', {
'_token': '{{ csrf_token() }}',
'diagnosis_id': diagnosis_id,
'value': val,
'type': type
}, function(success) {
console.log(success);
if (success.redirect) {
//window.location.href = '/diagnosis/edit/' + success.id;
window.history.pushState('edit', 'Title', '/diagnosis/edit/'+success.id);
}
});
}
HTML
<input class="saveonchange add_media id_input" type="text" name="wo_number" value="" id="wo_input"/>