怎么用变量输出  1 2 3 4 5 6 7 8 9 10 11 12 ...这种格式??01 02 03 04 05 06 07 08 09 10 11 12 ...又如何呢??001 002 003 004 005 006 007 008 009 010 011 012 ...??如果是字符串变量呢A B C D E F G ... X Y Z a b c d e f g ... x y z 就是把一个变量,做个循环,递增,,但是我不知道 怎么去 控制 它的输出 格式,%f 那些都用不了的在JAVASCRIPT中应该怎么做的,有什么函数或简单的方法?

解决方案 »

  1.   

    <script language="javascript">
    for(var i=1; i<110; i++){

    document.write(i);
    document.write(" ---- ");

    i<10?document.write("0"+i):document.write(i);

    document.write(" ---- ");
    i<100?(i<10?document.write("00"+i):document.write("0"+i)):document.write(i);

    document.write(" ---- ");
    i<27?document.write(String.fromCharCode(i+96)):null;

    document.write(" ---- ");
    i<27?document.write(String.fromCharCode(i+64)):null;



    document.write("<br>");
    }
    </script>