JavaScript - Need Help For 1 232 34543 Triangle
Hi there! I'm new to coding and i want do something like this with arrays and loops but i dont know how exactly:
1 232 34543 4567654 567898765 67890109876 7890123210987 890123454321098 90123456765432109 0123456789876543210 Thanks! Reply With Quote 01-15-2015, 04:59 PM #2 Philip M View Profile View Forum Posts Supreme Master coder! Join Date Jun 2002 Location London, England Posts 18,371 Thanks 204 Thanked 2,573 Times in 2,551 Posts As we say so often, this forum is not a free coding service. As a general rule, the people helping out in this forum don't write code for others (especially code that appears to be for homework), but try to help with fixing code that doesn't work. You may perhaps get someone to write this script for you, but you'll be far more likely to get help if you have made a substantial effort and written some code yourself. Then someone here will almost certainly help you correct/improve your work. All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit. Similar TutorialsOK I've been stuck on this problem for like 4 days already, so I'm resorting here. This is my problem Code: (A) (B) (C) (D) * ********** ********** * ** ********* ********* ** *** ******** ******** *** **** ******* ******* **** ***** ****** ****** ***** ****** ***** ***** ****** ******* **** **** ******* ******** *** *** ******** ********* ** ** ********* ********** * * ********** Now im suppose to write the script that makes patterns A-D stack on top of each other, so A on top, B under it, then C, and then D. I managed to get A and B with not many problems, but when it comes to C and D, I'm just confused on how to get them spaced over. Apparently I'm suppose to use the Pre tag, but im still not sure how to do that either. Im not asking for anybody to do this for me, all I need is a little guidance on how to start C and D. Here is what i have for A and B. I also did one for C, but as i said before, not sure on how i would have it space out in the loop. If you see any mistakes or have a better way of writing this, let me know please. Any help is appreciated. Thank you. Code: <script type = "text/javascript"> nextRow: for (var row = 1; row <= 10; ++row ) { document.writeln( "<br />" ); for ( var column = 1; column <= 10; ++column ) { if ( column > row ) continue nextRow; document.write( "*" ); } } nextRow: for (var row = 1; row <= 10; ++row ) { document.writeln( "<br />" ); for ( var column = 10; column >= 1; --column ) { if ( column < row ) continue nextRow; document.write( "*" ); } } nextRow: for (var row = 1; row <= 10; ++row ) { document.writeln( "<br />" ); for ( var column = 10; column >= 1; --column ) { if ( column < row ) continue nextRow; document.write( "*" ); } } </script> I know very little about javascript, but was wondering if something like this can be done? Would it be possible (with mootools or jquery) to have homepage that will rotate its home page content forwards and backwards based on either triangle or square? ie, you can rotate through 3, 4, etch home pages? Sort of like a slider, but it rotates off a center axis of the triangle or square? I need to draw like image 1 in file attach. But after i write code: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <script type="text/javascript"> function Ve() { var n = document.getElementById("txtGiatri").value; var i,j; for(i=1;i<=n;i++) { for(j=0;j<n-i;j++) document.getElementById ("place").innerHTML +=" "; for(j=i;j>0;j--) { document.getElementById ("place").innerHTML +=j; } document.getElementById ("place").innerHTML +="<br/>"; } } </script> <body> <table> <tr> <td><input name="txtGiatri" type="text" id="txtGiatri" /></td> <td><input name="btnVe" type="button" value="Ve" onclick="Ve();" /></td> </tr> <tr> <td><div id="place"></div></td> <td></td> </tr> </table> </body> </html> i only have like image 2. How i fixed it? |