Page 1 of 1
[code] [/code] advice sought
Posted: Wed Jan 21, 2009 10:48 pm
by Howard Somerset
I'm sure someone here will be able to help.
I'm wanting to display some tabular information on a forum - not this one.
I've seen it done before, and I believe the Code facility was used. But how can one align columns?
I'm wanting to display things such as
but with the 4 under 111, the 5 under 222, and the 6 under 333.
If Code is the right way to do it, is there any help text anywhere for such a facility?
Re: [code] [/code] advice sought
Posted: Wed Jan 21, 2009 10:57 pm
by Matt Morrison
Never used it before but having had a quick fiddle the 'code' function counts white spaces rather than cutting them out.
Usually on the web, white space is 'wrapped'
e.g. " " and " " will display the same in this post even though the first only has just 1 space in between the quotes and the second has 10 spaces.
The code function, however, will keep the white space in, and because it is displayed in a fixed-width font (all characters are the same width) you can make the 'columns' align by adding extra spaces to push the text along.
Unfortunately that's not made particular easy by the fact that the font you are typing your message (and your code) in is NOT fixed width, so you keep having to press preview to check what you are doing, or count the spaces.
This is just me freestyling, I'm sure someone has an easier method?
Re: [code] [/code] advice sought
Posted: Wed Jan 21, 2009 10:57 pm
by Charlie Reams
On some forums you can use [pre], but I don't know much about
Code: Select all
(insert your own apterous joke here.)
The easy solution to Matt's problem would be to write the post in some other editor, like Notepad.
Re: [code] [/code] advice sought
Posted: Wed Jan 21, 2009 11:02 pm
by Howard Somerset
Excellent. Thanks guys.

Re: [code] [/code] advice sought
Posted: Wed Jan 21, 2009 11:05 pm
by Matt Morrison
Code: Select all
$(document).ready( function() {
$('.nameSender').blur(function() {
$("#studentName").insertStudentName($(".nameSender").attr("value"));
return false
});
});
here's a much easier way, but expanding on what I said.
Put the code you want into a text editor, any one should do.
Use the tab key to indent the data to various extents, making your 'columns'.
Then just copy and paste it into this window between the code tags and just like it 'remembers' spaces, it remembers tab indents too.
Re: [code] [/code] advice sought
Posted: Wed Jan 21, 2009 11:11 pm
by Matt Morrison
Charlie Reams wrote:The easy solution to Matt's problem would be to write the post in some other editor, like Notepad.
Sorry if last post sounded a bit nonsense - had come to this solution myself Charlie and was trying it out... BUT
It only seems to keep proper track of the tab indents at the start of each line.
That's why the PHP code above looks fine, the only tab indents are at the start of the lines in the middle of the function.
But when I set up a perfectly aligned 'table' with tabs in the same PHP editor I was using (with fixed width font), the code comes out like this:
Code: Select all
WEEK: 1 2 3 4 5
Fav. word ALL LEG BOAST FACE CREAM
Fav. number 67 20 0 89.99 four
And when I pasted from this editor into Notepad, it turned out misaligned in there.
I hadn't give up, and tried making sure it was aligned perfectly in Notepad and then trying to copy it over here again. This gave:
Code: Select all
WEEK: 1 2 3 4 5
Fav. word ALL LEG BOAST FACE CREAM
Fav. number 67 20 0 89.99 four
So, not much help. Sorry. Looks like counting the individual spaces is oddly enough the best way?
Re: [code] [/code] advice sought
Posted: Wed Jan 21, 2009 11:19 pm
by Charlie Reams
The tabs might not map to the same number of spaces in your editor as they do on here.
Re: [code] [/code] advice sought
Posted: Wed Jan 21, 2009 11:25 pm
by Howard Somerset
Well I'm getting closer with your help, guys.
I may try Word with a fixed width font, and then with Word I can set the tab interval as I want, once I've worked out what is consistent with the forum. But that's for tomorrow.
At least this exercise is taking my mind off that diabolical football performance this evening.

Re: [code] [/code] advice sought
Posted: Wed Jan 21, 2009 11:58 pm
by Howard Somerset
Managed a correct display now by going back to the first two responses, one each from Matt and Charlie. I've used Notepad, and used spaces rather than tabs. All displayed perfectly.
So thanks again, guys.
I'll still keep trying a more acceptable way using tabs, though.