xecvantec
09-22-2011, 05:11 AM
I need to draw like image 1 in file attach.
But after i write 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?
But after i write 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?