Re: How to use TR to generate a table row
by kyle (Abbot) on Feb 05, 2007 at 15:17 UTC
|
Your earlier threads that might help:
The problem you're having is probably that the CGI Tr method is capitalized to avoid conflict with the tr operator.
| [reply] [d/l] |
Re: How to use TR to generate a table row
by davorg (Chancellor) on Feb 05, 2007 at 15:38 UTC
|
Most CGI.pm tutorials I've seen are just HTML-ized versions of the PERL doc inside of CGI.pm itself, which is of no help in this area.
Actually you're wrong there. The CGI.pm has a section called Non-Standard HTML Shortcuts, which says:
Because of conflicts with built-in Perl functions, the following functions begin with initial caps:
Select Tr Link Delete Accept Sub
It's looks to me as though this specifically addresses the problem that you're having.
| [reply] |
Re: How to use TR to generate a table row
by ww (Archbishop) on Feb 05, 2007 at 15:25 UTC
|
As to finding your prior posts (and I think this is a repeat), your PM login name appears at the top (generally, top right) of each page. Clicking on that link will take you to your home page, where you'll see a number (which is a link) adjacent to the word "writeups." Clicking that will take you to a complete list of the nodes you've written.
Alternately, you can use the Nodes You Wrote link in the sidebar (usually, left) and when that page opens, enter your login name in the "author" box to obtain the same information. | [reply] |
|
|
| [reply] |
|
|
| [reply] |
Re: How to use TR to generate a table row
by EvanK (Chaplain) on Feb 05, 2007 at 16:25 UTC
|
The CGI module in this usage is not very complex, it just makes use of anonymous or referenced hashes/arrays, which are a perpetual source of confusion. The important point to remember is that context counts!
Basically, any html element can be created with its name as the function name (but for the differences noted by davorg) where attributes are passed in a hash reference, and contents are passed in a list or array:
print comment('this creates one big blockquote');
print blockquote(
{-cite => 'http://www.example.com/biblio'},
'The quick fox jumps over the lazy dog.',
br(),
strong('See citation for details')
);
Additionally, passing an array reference (or anonymous array) wraps each element of the referenced array in a seperate parent tag:
print comment('this creates two smaller blockquotes');
print blockquote(
{-cite => 'http://www.example.com/biblio'},
[
'The quick fox jumps over the lazy dog.',
strong('See citation for details')
]
);
So the two code snippets above generate this output (ive cleaned up the spacing manually, mind you):
<!-- this creates one big blockquote -->
<blockquote cite="http://www.example.com/biblio">
The quick fox jumps over the lazy dog.
<br />
<strong>
See citation for details
</strong>
</blockquote>
<!-- this creates two smaller blockquotes -->
<blockquote cite="http://www.example.com/biblio">
The quick fox jumps over the lazy dog.
</blockquote>
<blockquote cite="http://www.example.com/biblio">
<strong>
See citation for details
</strong>
</blockquote>
__________ The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.
- Terry Pratchett
| [reply] [d/l] [select] |
Re: How to use TR to generate a table row
by EvanK (Chaplain) on Feb 05, 2007 at 15:18 UTC
|
I believe the function is Tr(), not tr(), so as not to conflict with the tr// translation syntax.
As far as a CGI tutorial, I can't help since I prefer the use of templates to the CGI html functions. | [reply] [d/l] [select] |
|
|
Changing it to Tr from tr definitely helped, now the first row is not printing at all, but the rest (which I did not show you the code for) does print, but without the first row, it prints in a rather messy fashion - the column cells do not have the right size.
Again,what I am trying to do is give Tr a reference to a hash which has all of the first row cells in it. Can I do that?
| [reply] |
|
|
Without seeing the code it's hard to know what the problem is. We could guess, but that would almost certainly be a waste of both your time and ours.
Again,what I am trying to do is give Tr a reference to a hash which has all of the first row cells in it. Can I do that?
You seem to be changing your story. Previously you have been telling us that you are trying to pass Tr an array. Now you say it's a hash. Which is it?
A table row doesn't contain data directly. They are supposed to be in td or th elements. Given an array that contains the data for a table row, you need code like this (again, assuming the function-oriented interface to CGI.pm as, in my opinion, it's far easier to use):
print Tr(td(\@array));
| [reply] [d/l] |
Re: How to use TR to generate a table row
by TOD (Friar) on Feb 05, 2007 at 16:24 UTC
|
the question is: what stops when? does your script on the server abort, or can't you just see results in your browser? did you try using Carp.pm? because, if your script works properly, and you don't see the expected result in your browser, you might have forgotten the "tbody" tag. | [reply] |
|
|
| [reply] |