First time here? Check out the FAQ!

Ask Your Question
2

side by side html tables

asked 13 years ago

calc314 gravatar image

Is there a way to display two html tables (of different sizes) side by side?

Here is a simple, silly example. Can I display the arrays below in side by side tables?

a=[[i,i^2] for i in range(0,10)]

b=[[i,i^3] for i in range(0,15)]

html.table(a)

html.table(b)

Preview: (hide)

4 Answers

Sort by » oldest newest most voted
5

answered 13 years ago

benjaminfjones gravatar image

You can insert html commands to wrap the two tables into a larger table. Something like:

a=[[i,i^2] for i in range(0,10)]
b=[[i,i^3] for i in range(0,15)]
html('<table><tr><td>')
html.table(a)
html('</td><td>')
html.table(b)
html('</td></tr></table>')

You can change the table (and row and column) style to your liking by modifying the html commands that wrap the html.table calls.

Preview: (hide)
link

Comments

This is also a good answer.

kcrisman gravatar imagekcrisman ( 13 years ago )
1

answered 13 years ago

kcrisman gravatar image

If your tables are the same length, you can try to make just one table - I do this sometimes.

a=[[i,i^2] for i in range(0,10)]
b=[[i,i^3] for i in range(0,10)]
c=[flatten(z) for z in zip(a,b)]
html.table(c,header=['x','f(x)','y','g(y)'])

As a corollary for your case (not the same length), it's possible to insert None and then replace that with ''. Here's one I've actually used. It's a bit annoying, but doable. In this case I really didn't know how big they would be ahead of time, because n was potentially much bigger than 7.

n=7
L = map(None,[p for p in prime_range(n+1) if p%4==1],[p for p in prime_range(n+1) if p%4==3])
L = [['',l[1]] if l[0] is None else l for l in L]
T = [['$p\equiv 1\\text{ mod }(4)$','$p\equiv 3\\text{ mod }(4)$']]
html.table(T+L,header=True)
Preview: (hide)
link
1

answered 13 years ago

Eugene gravatar image

You can also play with div tags:

a=[[i,i^2] for i in range(0,10)]
b=[[i,i^3] for i in range(0,15)]

html('<div style="float:left; width:256px;">')
html.table(a)
html('</div><div style="float:right; width:256px">')
html.table(b)
html('</div>')
Preview: (hide)
link

Comments

From a web design perspective, this is the proper way to do it.

process91 gravatar imageprocess91 ( 13 years ago )
0

answered 13 years ago

calc314 gravatar image

Thanks for all the help. This is working great!

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 13 years ago

Seen: 1,537 times

Last updated: Oct 05 '11