Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Help to draw number triangle in div use javascipt
Old 09-22-2011, 12:47 AM Help to draw number triangle in div use javascipt
Junior Talker

Posts: 1
Trades: 0
I need to draw like image 1 in file attach.


But after i write code:
Code:
<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 +="&nbsp;";
       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?
Attached Images
File Type: jpg 1.jpg (43.7 KB, 12 views)
File Type: jpg 2.JPG (12.0 KB, 9 views)
xecvantec is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-23-2011, 09:18 PM Re: Help to draw number triangle in div use javascipt
Physicsguy's Avatar
404 - Title not found

Posts: 919
Name: Scott Kaye
Location: Ontario
Trades: 0
All you need is some spacing. Try adding some more &nbsp;s in between your numbers (after the number is echoed).

EDIT: Oops, didn't look quite that closely. I see, it's more than that. I'll try to think of something. Sorry!
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!

Last edited by Physicsguy; 09-23-2011 at 09:21 PM..
Physicsguy is offline
Reply With Quote
View Public Profile
 
Old 09-24-2011, 01:11 PM Re: Help to draw number triangle in div use javascipt
Super Spam Talker

Posts: 879
Name: Paul W
Trades: 0
Quote:
Originally Posted by Physicsguy View Post
I see, it's more than that. I'll try to think of something. Sorry!
I wouldn't - make him solve it himself!

To the OP: lesson 1: don't just write (copy?) some code and hope it might magically provide the solution. Try phrasing the aim in plain English. Actually writing that down should clarify and lead you to a solution.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


*** New:
Please login or register to view this content. Registration is FREE

Last edited by PaulW; 09-25-2011 at 11:34 AM..
PaulW is online now
Reply With Quote
View Public Profile
 
Reply     « Reply to Help to draw number triangle in div use javascipt
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11555 seconds with 13 queries