User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 402,714 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,385 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1626 | Replies: 7
Reply
Join Date: Nov 2006
Posts: 11
Reputation: spike29 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
spike29 spike29 is offline Offline
Newbie Poster

javaScript/XHTML.

  #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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2006
Location: India
Posts: 1,289
Reputation: vishesh is on a distinguished road 
Rep Power: 4
Solved Threads: 32
vishesh's Avatar
vishesh vishesh is offline Offline
Nearly a Posting Virtuoso

Re: javaScript/XHTML.

  #2  
Nov 26th, 2006
i didnt understand whats
N 10* 100* 1000*
Reply With Quote  
Join Date: Oct 2006
Location: India
Posts: 1,289
Reputation: vishesh is on a distinguished road 
Rep Power: 4
Solved Threads: 32
vishesh's Avatar
vishesh vishesh is offline Offline
Nearly a Posting Virtuoso

Re: javaScript/XHTML.

  #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  
Join Date: Nov 2006
Posts: 11
Reputation: spike29 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
spike29 spike29 is offline Offline
Newbie Poster

Re: javaScript/XHTML.

  #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  
Join Date: Jul 2005
Location: india
Posts: 143
Reputation: katarey is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 15
katarey's Avatar
katarey katarey is offline Offline
Junior Poster

Solution Re: javaScript/XHTML.

  #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 3:51 pm. Reason: Adding some code
Freelance Web Designer & Developer
Http//www.Katarey.com
Reply With Quote  
Join Date: Nov 2006
Posts: 11
Reputation: spike29 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
spike29 spike29 is offline Offline
Newbie Poster

Re: javaScript/XHTML.

  #6  
Nov 26th, 2006
ohh!! thx man ...
Reply With Quote  
Join Date: Oct 2006
Location: India
Posts: 1,289
Reputation: vishesh is on a distinguished road 
Rep Power: 4
Solved Threads: 32
vishesh's Avatar
vishesh vishesh is offline Offline
Nearly a Posting Virtuoso

Re: javaScript/XHTML.

  #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
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 5:05 pm.
Reply With Quote  
Join Date: Nov 2006
Posts: 11
Reputation: spike29 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
spike29 spike29 is offline Offline
Newbie Poster

Re: javaScript/XHTML.

  #8  
Nov 26th, 2006
oh! ok thx a lot again man
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 6:42 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC