Friday, 15 April 2011

jquery - Javascript addition query -



jquery - Javascript addition query -

don't sense foolishness in question. below scenario. please advice

var num = 02; var add together = num + 1 ;

getting result 3, need 03. possible.

you'll need write padding function:

function strpad(string, length, padchar) { var o = string.tostring(); if(!padchar) { padchar = '0'; } while (o.length < length) { o = padchar + o; } homecoming o; };

and phone call using:

var num = 3; var add together = strpad((3 + 1), 2); // homecoming '04' string.

javascript jquery

No comments:

Post a Comment