Hi everyone, I am using the for loop function. I feel that my code is correct but something is wrong. I check for brackets and semicolon and they are in the right places and the right amount. Can someone look at my code and let me know why it is not displaying/functioning. I am using the decrement operator with the for loop. This code should make my code look like 0 1 2 etc function ForTest() { var OutPut=""; FillArray() for (var i=Numbers.length; i >= 0; i--) { OutPut = OutPut + Numbers[i] + "\r"; } document.frmMain.txtaOutput.value = OutPut; } Code (markup): and I also tried it this way function ForTest() { var OutPut=""; FillArray() { for (var i = Numbers.length - 1; i >= 0; i--); { OutPut = OutPut + Numbers[i] + "\r"; } document.frmMain.txtaOutput.value = OutPut; } } Code (markup): neither way is making my document work.
Never seen such a like for loop before...do you know the basics? for(i = 0; i < 4; i++){ document.write(i+"<br />"); } Code (markup): Will print out: 1 2 3
You may need to use window.Numbers if this var is from the global scope. Give a bigger piece of code, cause that one is just fine, the problem is somewhere else in the code.
function ForTest(){ FillArray(); var OutPut = "", i = Numbers.length; for ( ; i >= 0; i--) OutPut += Numbers[i] + "\n"; document.frmMain.txtaOutput.value = OutPut; } PHP: Post the FillArray() function.