Jump to content

Search the Community

Showing results for tags 'for loop'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH


  • Community Calendar




Website URL








Found 8 results

  1. I do not get the input value x to add to i in the for loop. What am I doing wrong? <!DOCTYPE html> <html> <body> <input id="inp" type="number" > </input> <button type="button" onclick=myFunction() > click</button> <p id="result" > </p> <script> function myFunction(){ var txt= ""; res = document.getElementById("result"); res.innerHTML=""; var x= document.getElementById("inp").value; var i= 0; for ( ; i < 20; i++) { txt += "input" + i + "<br>"; i = i += x ; } res.innerHTML=txt; console.log(txt += "input is " + (i+x) + "<br>"); console.log(i); } </script> </body> </html>
  2. Greetings! I do not understand why I have to describe that variable " ". http://www.w3schools.com/js/tryit.asp?filename=tryjs_loop_for_ex When I put a letter in it, it returns "aThe number is 0 (...)" only the first character, not every loop. So why we need to describe empty value. Why we want to write there nothing ->
  3. Vague Notice

    Hi, This block code is from W3schools tutorials: <?php $cars = array("Volvo", "BMW", "Toyota"); $arrlength = count($cars); for($x = 0; $x <= $arrlength; $x++) { echo $cars[$x]; echo "<br>"; } ?> The original block was without the equal sign in $x <= $arrlength; I have added the equal sign to see what would happen. I got the same result but followed with: Notice: Undefined offset: 3 in C:\xampp\htdocs\Testing\testing.php on line 14 I would appreciate it if someone would explain why I am getting this notice and its meaning. I thought the loop will stop and give the same result without any notice when it hits no value for the equal sign.
  4. how incurse for loop font size

    Hello, Can anyone tell me how I create a for loop which incurs a sentence of 10 pixels to 100 pixels? So the word sentence font-size from 10 to 100 px. for ($x = "sentence"; $x "font-size" ; $xxx) { echo "$x <br>";} thanks in advance.
  5. var text="";

    Hi, I just started to study javascript and I came across in one of your page to the following notation: var text=""; The page is from w3school tutorial: http://www.w3schools.com/js/tryit.asp?filename=tryjs_loop_for_ex I do not understand what it means and why should be used in the loop of the above example. I tried to define var text; in its place but the result is: undefinedThe number is 0The number is 1The number is 2The number is 3The number is 4 The only difference is the world 'undefined' at the beginning of the first line. Many thanks in advance for your help
  6. For Loop explanation

    In the For Loop tutorial of w3si did'nt understand some code line of the following js code, i indicated it below ------------------------------------------------------------------------------------------------------------------------<button onclick="myFunction()">Try it</button><p id="demo"></p> <script>function myFunction(){var x="",i; <---[ what this type of var means, and wat this "" means, ]for (i=0;i<5;i++) { x=x + "The number is " + i + "<br>"; <---[ What the x=x means] }document.getElementById("demo").innerHTML=x;}</script>------------------------------------------------------------------------------------------------------------------------Actually i tried and found it can be write another method, but why w3s written the above indicated method, and not mentioned anywhere about this kind of for loop method.
  7. Hi All,I am a newbe in javascript but curious to learn javascript. I have made a table using divs by javascript for loop and want to add diffrent content in diffrent divs. for example: first div should contain an image, second one should contain an paragraph, third one should contain a button element etc, but I don't know how this to be done.so please anyone help me to make me aware of this idea. here is my code. <style type="text/css">.parent { width: 1010px; height: auto; border: 1px solid red; margin: 0 auto; clear: both; display: table;}.child{ width: 200px; height: 100px; border: 1px solid blue; text-align: center; display: table-cell;}</style><script type="text/javascript">document.write('<div class="parent">');var x = 0;while (x<10) {document.write('<div class="child"></div>');x++;}document.write('</div>');</script> thanks in advance.
  8. for loop within...

    Is it valid to have a for loop within a for loop? I tried is and the browser loops endless, if i do not close the browser tab it will not stop looping. So, do you think that by definition is invalid or that it is sth else that causes the above problem?