db1.transaction(function(transaction)
{
transaction.executeSql('SELECT * FROM customer where cust_code=(select max(cust_code) from customer) ', [], function(transaction, result) {
var len = result.rows.length;
if (result.rows.length != 0 )
{
for (var i = 0; i < result.rows.length; i++)
{
var row = result.rows.item(i);
custcode=row.cust_code;
}
console.log("custcod",custcode);
var number=parseInt(custcode.substring(5,6),10)+1;
console.log(number);
value=zeroFill(number,3);
console.log(value);
}
else
{
var number=parseInt(s.substring(5,6),10)+1;
console.log(number);
value=zeroFill(number,3);
}
function zeroFill( number, width )
{
console.log("NUMBER:",number);
var str = '' + number;
while (str.length < width)
{
str = '0' + str;
}
return 'C0000'+str;
}
This code works fine till the value is C000010 after that,C000010 is repeated,increment is not done how can I increment it ??