I have text that needs to be automatically split in half and presented in two columns (side by side). Ideas on how this can be done? Note: Text will be drawn from one DB field (hopefully). The columns (in a div) would not be presized except for width - who knows how long the text blurb will be? ex: text starts here, blah ------|---- automatically HERE. Wouldn't blah, blah, blah, blah, blah -|---- it be nice? Blah, blah text here that should ------|---- blah, blah, blah, blah, blah blah, blah, blah, blah, blah -|---- from other side, blah text here that should ------|---- blah, blah, blah, blah, blah CONTINUE this paragraph --|
I have a simple example here on how to populate the two columns... this is not intended to be a total solution... just an example that might help you get started. See the code below: <!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> <title>Untitled Page</title> <SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript> <!-- function button1_onclick() { var rawText = 'ColOneText... ColOneText... ColOneText... ColOneText... ColOneText... ColOneText... ColOneText... ColOneText... ColOneText... ColOneText... ColOneText... ColTwoText... ColTwoText... ColTwoText... ColTwoText... ColTwoText... ColTwoText... ColTwoText... ColTwoText... ColTwoText... ColTwoText... ColTwoText... '; var colOneText = rawText.substring(0,154); var colTwoText = rawText.substring(154,309); var col1 = document.getElementById('colOne'); col1.innerHTML = colOneText; var col2 = document.getElementById('colTwo'); col2.innerHTML = colTwoText; } //--> </SCRIPT> </head> <body> <TABLE cellSpacing=1 cellPadding=1 width="75%" border=1> <TR> <TD id='colOne'>this is col 1</TD> <TD id='colTwo'>this is col 2</TD></TR> <TR> <TD colspan=2><INPUT id=button1 style="WIDTH: 117px; HEIGHT: 24px" type=button size=40 value="Click Me" name=button1 LANGUAGE=javascript onclick="return button1_onclick()"></TD> </TR></TABLE> </body> </html>
The previous reply tends to be pretty correct, you would just need to have a script that would pull the information out of your database and then create a table with 2 identical tables (heights and width) and have your code auto drop that text that was pulled from the database into both columns of your database and this should work perfectly for what you are doing.
See Gecko 1.8 For Web Developers: Columns, and A List Apart: Introducing the CSS3 Multi-Column Module. Both are old, but there's been little or no change since. If you choose to force flowed columns programmatically, do it server side, and use floated or inline-block containers for the columns. Do not use tables, as that would be neither well structured nor semantic markup. cheers, gary
Thanks guys. The new wunderkind of the company came up with a similar js way to do it (" " var/2), and that's what the boss is going with. Personally, I would have preferred a server-side approach (as suggested), but it's a moot point now. Thanks again.