I have a table with data from check sheets like: bank, account, agency and sheet number, everything was fine so far, but today a customer came with an itau receipt and it has 3 letters followed by a hyphen and the number sequence. example: ABC-7852
The numbers of the sheets are sequential incremented by +1, in the sheets of itaú the letters do not change, I tried using the function explode do php
and I was able to make it work disregarding everything before (-)
and then concatenating.
No JQuery
can I use explode
or some similar function? To repeat the letters in all the lines and to increment only the numeric values.
ABC-7852
ABC-7853
ABC-7854
ABC-7855
follows the current code.
$(document).on('blur', '.ncheque', function() {
var chqs = $('.ncheque');
var index = null;
var valor = parseInt(this.value);
indice = chqs.index(this);
if (valor) {
$('.ncheque').each(function(index) {
if (index > indice) {
$(this).val(valor + index);
}
});
} else {
$('.ncheque').val('');
}
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divclass="form-horizontal">
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="txtCh1"></label>
<div class="col-md-4">
<input id="txtCh1" name="txtCh1" type="text" placeholder="Folha cheque 1" class="form-control input-md ncheque">
<input id="txtCh2" name="txtCh2" type="text" placeholder="Folha cheque 2" class="form-control input-md ncheque">
<input id="txtCh3" name="txtCh3" type="text" placeholder="Folha cheque 3" class="form-control input-md ncheque">
<input id="txtCh4" name="txtCh4" type="text" placeholder="Folha cheque 4" class="form-control input-md ncheque">
</div>
</div>
</div>