My code generates a random last digit code when executed. When I want it to give a specific code.
$(document).ready(function() {
function invoiceid() {
var d = new Date().getTime();
var uuid = 'GA00444x'.replace(/[xy]/g, function(c) {
var r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16);
return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
});
return uuid;
};
function shortInvoiceId() {
return invoiceid().substr(0, 18);
}
$('#invoiceid').on('load', function() {
$('#uuid').html(shortInvoiceId());
});
$('#uuid').html(shortInvoiceId());
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<div id="uuid"></div>