/    Sign up×
Community /Pin to ProfileBookmark

Certain columns table script

Hi there,

This is what I would like the script to do:

I want to loop to a certain number and produce each number in a table.

I want the table to only be 10 columns and then it should make a new <tr>

How can I do this?

Thanks in advance

jmcall10

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERMar 17.2007 — This should help:
[code=php]
<html>
<head>
<title>Table Display</title>
<script type="text/javascript">
function MakeTable(tbl_limit) {
document.write('<table border="1"><tr>');
var j = 1;
for (i=0; i<tbl_limit; i++) {
document.write('<td>'+j+'</td>');
if (j % 10 == 0) { document.write('</tr><tr>'); }
j++;
}
document.write('</tr></table>');
}

</script>
</head>
<body onLoad="MakeTable('50')">
</body>
</html>
[/code]

You could use the 'i' instead and remove the 'j' logic with a little tweak of the code.
Copy linkTweet thisAlerts:
@samanyoluMar 17.2007 —  <br/>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;addition&lt;/title&gt;

&lt;script type="text/javascript"&gt;

document.write('&lt;table border="1" cellpadding="5" bgcolor="#00FF66"&gt;') <br/>
for(i=1;i&lt;=11;i++){ <br/>
document.write('&lt;tr&gt;') <br/>
for(k=1;k&lt;=11;k++){

document.write('&lt;td&gt;'+((i+k)-2)+'&lt;/td&gt;')}

document.write('&lt;/tr&gt;')}
document.write('&lt;/table&gt;')

&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;


<br/>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;multiplication&lt;/title&gt;

&lt;script type="text/javascript"&gt;

document.write('&lt;table border="1" cellpadding="5" bgcolor="#00FF66"&gt;') <br/>
for(i=1;i&lt;=10;i++){ <br/>
document.write('&lt;tr&gt;') <br/>
for(k=1;k&lt;=10;k++){ <br/>
document.write('&lt;td&gt;'+i*k+'&lt;/td&gt;')}

document.write('&lt;/tr&gt;')}
document.write('&lt;/table&gt;')

&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@jmcall10authorMar 17.2007 — That has worked a treat thanks

jmcall10
×

Success!

Help @jmcall10 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...