I have a table with a text box column and I want to get the old value and set it to the text box onchange
.
<span class="txt_b">
<input type="number" name="" value="<?php echo $req; ?>" onchange="onChangeTest(this)" onchange="setoldvalue(this)" oldvalue="" class="input_md radious_all innershadow padding_control" id ="tk" style="width:60px;" id="qty_req_<?php echo $i; ?>" onblur="editBucket('<?php echo $row_id; ?>','<?php echo $item['Item']['code']; ?>',$('#qty_war_<?php echo $i; ?>').val(),this.value,'<?php echo $date; ?>',$('#stock_notes_<?php echo $i; ?>').val(),'<?php echo $item['Item']['pack_size']; ?>')"/>
</span>
</div>
<input type="hidden" name="product" id="qty_reqty_" class="product" value="qty_reqty_<?php echo $i; ?>" />
</div>
<script>
function getoldvalue()
{
$('input').on('focusin', function(){
console.log("Saving value " + $(this).val());
$(this).data('val', $(this).val());
});
$('input').on('change', function(){
var prev = $(this).data('val');
$('input').val(prev);
console.log(s);
var current = $(this).val();
console.log("Prev value " + prev);
console.log("New value " + current);
});
I am struggling with setting the value to the text box. How to it by id
?
this is my jquery dialogbox
function editCart(id,code,stock_wh,stock_rq,date,notes,pack){
if((stock_rq%pack) != 0){
$('<div></div>').appendTo('body')
.html('<div id="dialog"><h3>The quantity should be multiple of pack size, do you wish to continue with the quantity entered?</h3></div>')
.dialog({
modal: true,
title: 'message',
zIndex: 10000,
autoOpen: true,
width: 'auto',
resizable: true,
buttons: {
Yes: function () {
doFunctionForYes();
$(this).dialog("close");
},
No: function () {
doFunctionForNo();
$(this).dialog("close");
}
},
close: function (event, ui) {
$(this).remove();
}
});
$('#msg').hide();
function doFunctionForYes() {
$('#msg').show();
}
function doFunctionForNo() {
alert("doFunctionForNo");
});
}
}