javaScript/XHTML.

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Nov 2006
Posts: 11
Reputation: spike29 is an unknown quantity at this point 
Solved Threads: 0
spike29 spike29 is offline Offline
Newbie Poster

javaScript/XHTML.

 
0
  #1
Nov 26th, 2006
Question for a Book (Inernet & WWW How to program)

Write a JavaScript program that uses Looping to print the following table of valuses. Qutput the results in an XHTML table.

N 10* 100* 1000*
1 10 100 1000
2 20 200 2000
3 30 300 3000
4 40 400 4000
5 50 500 5000
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 1,311
Reputation: vishesh is on a distinguished road 
Solved Threads: 36
vishesh's Avatar
vishesh vishesh is offline Offline
Nearly a Posting Virtuoso

Re: javaScript/XHTML.

 
0
  #2
Nov 26th, 2006
i didnt understand whats
N 10* 100* 1000*
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 1,311
Reputation: vishesh is on a distinguished road 
Solved Threads: 36
vishesh's Avatar
vishesh vishesh is offline Offline
Nearly a Posting Virtuoso

Re: javaScript/XHTML.

 
0
  #3
Nov 26th, 2006
wait:
[html]
<!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" xml:lang="en" lang="en">

<head>
<title></title>
<script language="JavaScript" type="text/javascript">
/*<![CDATA[*/
var a=10;
document.write("<table border='1'>")
document.write("<tr><td>N</td><td>10*</td><td>100*</td><td>1000*</td></tr>")
for(i=1;i<=5;i++)
{
document.write("<tr><td>"+i+"</td><td>"+i*a+"</td><td>"+i*a*a+"</td><td>"+i*a*a*a+"</td></tr>");
}
document.write("</table>");
/*]]>*/
</script>
</head>

<body>

</body>

</html>
[/html]
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 11
Reputation: spike29 is an unknown quantity at this point 
Solved Threads: 0
spike29 spike29 is offline Offline
Newbie Poster

Re: javaScript/XHTML.

 
0
  #4
Nov 26th, 2006
OMG! thank your very much. Just one question how did you use looping. I mean in which lines? thx again
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 154
Reputation: katarey is an unknown quantity at this point 
Solved Threads: 20
katarey's Avatar
katarey katarey is offline Offline
Junior Poster

Re: javaScript/XHTML.

 
0
  #5
Nov 26th, 2006
Hi There,

Well code that wrote by vishesh doing the same thing that you want
Just he miss ";" two place, just add and code will run

And you can use the this code as well


[HTML]
<!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=iso-8859-1" />
<title>Untitled Document</title>
<script language="JavaScript" type="text/javascript">
//<![CDATA[

document.write("<table width='600' border='1' cellspacing='3' cellpadding='3'>");
document.write("<tr>");
document.write("<th>N</th>");
document.write("<th>10*</th>");
document.write("<th>100*</th>");
document.write("<th>1000*</th>");
document.write("</tr>");

//This is Looping
var num = 1;

for (var x=1; x <= 5; x++)
{
document.write("<tr><td>" + num*1 + "</td><td>" + num*10 + "</td><td>" + num*100 + "</td><td>" + num * 1000 + "</td></tr>");
num = num + 1;
}
document.write("</table>");
//]]>
</script>
</head>
<body>
</body>
</html>

[/HTML]

sorry for editing this post again:

here the validation result

http://validator.w3.org/check?uri=ht...doctype=Inline


Best regards,
Rahul Dev
Last edited by katarey; Nov 26th, 2006 at 4:51 pm. Reason: Adding some code
Freelance Web Designer & Developer
Http//www.Katarey.com
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 11
Reputation: spike29 is an unknown quantity at this point 
Solved Threads: 0
spike29 spike29 is offline Offline
Newbie Poster

Re: javaScript/XHTML.

 
0
  #6
Nov 26th, 2006
ohh!! thx man ...
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 1,311
Reputation: vishesh is on a distinguished road 
Solved Threads: 36
vishesh's Avatar
vishesh vishesh is offline Offline
Nearly a Posting Virtuoso

Re: javaScript/XHTML.

 
0
  #7
Nov 26th, 2006
OMG! thank your very much. Just one question how did you use looping. I mean in which lines? thx again
  for(i=1;i<=5;i++)
  {
    document.write("<tr><td>"+i+"</td><td>"+i*a+"</td><td>"+i*a*a+"</td><td>"+i*a*a*a+"</td></tr>");
}
this is for loop. the for loop first initialises variable i to 1i=1 and everytime increments it by 1i++ until i becomes greater than or equal to 5. And every time i increments it executes
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. document.write("<tr><td>"+i+"</td><td>"+i*a+"</td><td>"+i*a*a+"</td><td>"+i*a*a*a+"</td></tr>");
this line just write the table row and cells.
Last edited by vishesh; Nov 26th, 2006 at 6:05 pm.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 11
Reputation: spike29 is an unknown quantity at this point 
Solved Threads: 0
spike29 spike29 is offline Offline
Newbie Poster

Re: javaScript/XHTML.

 
0
  #8
Nov 26th, 2006
oh! ok thx a lot again man
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC