I want the value of a variable to always have 6 characters. If it has less, I want zero’s added to the end, and if it has more I just want the end of it cut off. Any suggestions on how to do it?
[CODE] while (theVariable.length < 6){theVariable = theVariable + "0";} [/CODE]
[CODE] if (theVariable.length > 6){theVariable.length = 6;} [/CODE]
<i> </i><script type="text/javascrpit"> var k = "This is more than six"; if(k.length > 6){ k = k.substr(0, 6); } alert(k); </script>
Help @heavenly_blue spread the word by sharing this article on Twitter...