-1

My patient number(pnum) need to have a autonumber, like BLHC-2014-0001. I need to automatically have the BLHC-current year-and auto increment of the number with 4 digits when i input new record.

1 Answers1

1
function autonum(){                           
    var c ='BLHC-2014-0001';

    var d = c.split("-");
    var e = d[2];
    var f = parseInt(e,10);
    var g = f+1;        
    var str = '' + g;
    var pad = "0000";    
    var resu = str.length < 4 ? (pad+str).slice(-4) : str;
    var lt = d[0]+'-'+d[1]+'-'+resu;               
    document.getElementById("pnum").value =lt;
}
LOKESH
  • 1,303
  • 1
  • 16
  • 29