div question

A

Aaron Fude

Hi,

Is there a way to define the content of a div or a span in one place, but
then place it in the document in another place? I do not want to do absolute
position. I will probably want to include that span in a table cell. The
reason I want to do this is to make the table code nice and compact and to
be able to see the table structure even if the div has long content.

Many thank in advance,

Aaron Fude
 
R

rf

Aaron Fude said:
Hi,

Is there a way to define the content of a div or a span in one place, but
then place it in the document in another place? I do not want to do absolute
position. I will probably want to include that span in a table cell. The
reason I want to do this is to make the table code nice and compact and to
be able to see the table structure even if the div has long content.

No.

Well... yes if you code your server side process correctly.

But why bother, why should a table cell contain so much anyway, that is if
it *is* tabular data?
 
B

brucie

in post: <
Aaron Fude said:
Is there a way to define the content of a div or a span in one place, but
then place it in the document in another place?
http://allmyfaqs.com/faq.pl?Include_one_file_in_another

The reason I want to do this is to make the table code nice and
compact and to be able to see the table structure even if the div has
long content.

thats fine using the server side options at the link above before the
server does its majic but the end result spat out at the browser end
will have the <td> containing goodies.

and just in case you're using <table>s for layouts. <smack on wrist/>
stop it. use css.
 
A

Aaron Fude

brucie said:
in post: <

thats fine using the server side options at the link above before the
server does its majic but the end result spat out at the browser end
will have the <td> containing goodies.

and just in case you're using <table>s for layouts. <smack on wrist/>
stop it. use css.

ok, ok - I'll reveal what I'm really trying to do. I have a page with a lot
of content. It is tablular data and the able has 1000 lines. I was planning
to break it up into 20 tables with 50 rows each. I will then use COOLjsTree
(http://javascript.cooldev.com) to hide all but one table. The darn thing
is, COOLjsTree requires its HTML content to be a valid javascript string
which is cubersome for a table with 50 lines. So I thought I would put that
table in a div and just mention the dive in the javascript string.

Here's an example for COOLjsTree developers (which I think is ugly):

var t1 = '<table bgcolor="#4682B4" width="400" cellspacing="0"
cellpadding="0" border="0"><tr><td align=center><font
color=white><b>Personal Info</b></font></td><tr></table>';
var f1 = '</a><table width="400" cellspacing="0" cellpadding="0"
border="0"><tr><td bgcolor="#EEEEEE">';
f1 += '<table width="100%" cellspacing="2" cellpadding="2" border="0">';
f1 += '<form action="javascript:alert(\'Submitted\');" method="get">';
f1 += '<tr><td><p class="last">First Name</td><td><input
type="text"></td></tr>';
f1 += '<tr><td><p class="last">Last Name</td><td><input
type="text"></td></tr>';
f1 += '<tr><td><p class="last">Age</td><td><select><option>from 10 to
15<option>from 16 to 20<option>from 21 to 30<option>from 31 to
40<option>older 40</select><td></tr>';
f1 += '<tr><td colspan=2 align=center><input type="submit"
value="Submit">&nbsp;<input type="reset" value="Reset"></td></tr>';
f1 += '</form>';
f1 += '</table></td></tr></table>';

.... lator on f1 is used:

var FORM_NODES = [
[t1, null, null,
[f1, null, null],
],


SO, I'm looking to avoid creating a long javascript string wih HTML content.
 
M

Mark Tranchant

Aaron said:
ok, ok - I'll reveal what I'm really trying to do. I have a page with a lot
of content. It is tablular data and the able has 1000 lines. I was planning
to break it up into 20 tables with 50 rows each. I will then use COOLjsTree
(http://javascript.cooldev.com) to hide all but one table. The darn thing
is, COOLjsTree requires its HTML content to be a valid javascript string
which is cubersome for a table with 50 lines. So I thought I would put that
table in a div and just mention the dive in the javascript string.

Yuk. Use PHP and put the table content into a database. Then you can
dynamically generate separate pages for each of the 20 sub-tables.

PHP and MySQL rules, and takes way less time to learn than you might
think. My site is entirely generated thusly, and performance is
excellent, even on the old P100 that's serving it.
 
D

Dylan Parry

Aaron said:
I will then use COOLjsTree (http://javascript.cooldev.com) to hide all
but one table. The darn thing is, COOLjsTree requires its HTML content
to be a valid javascript string which is cubersome for a table with 50
lines. So I thought I would put that table in a div and just mention the
dive in the javascript string.

Hmm, that's a damned ugly way of doing it. A better idea, that will still
work when JavaScript is disabled, would be to give each table an id (eg.
table1, table2, table3 etc) and then have a script that is called through
the onload() event in the body element.

The script would then loop through each of the table ids and set the
display property for that element to "none", obviously leaving one of the
tables displayed.

Then it's just a matter of creating a link for each table that when
clicked does the opposite of the onload() script. These links can also be
written out with JavaScript so that script-disabled browsers don't see
them.

See http://www.webpageworkshop.co.uk/main/article11 for an example of how
this can be done with lists. Adapting it to table shouldn't be too hard a
task.
 
W

Webcastmaker

ok, ok - I'll reveal what I'm really trying to do....

Oh you are headed in the right direction...
I have a page with a lot...
<snip>

Is putting each set of 50 on a different page not an option? With a
link to all 20 pages included somewhere on each page so you can jump
around. That would probably work on all browsers. If you want
javascript, then google "collapsible div DHTML" and you will be
rewarded with a ton of examples.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top