'I want to order id auto genarate and set text field, below function dosen't working. Is it correct?
I want to order id auto genarate and set text field, below function dosen't working. Is it correct?
function generateOrderID() {
try {
let lastOrderId = orderDB[orderDB.length-1].getOrderId();
let newOrderId = parseInt(lastOrderId.substring(1,7))+1;
if (newOrderId < 10) {
$("#txtOrderId").val('D00-00'+newOrderId);
}else if (newOrderId < 100) {
$("#txtOrderId").val('D00-0'+newOrderId);
} else {
$("#txtOrderId").val('D00-'+newOrderId);
}
} catch (e) {
$("#txtOrderId").val("D00-001");
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
