Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Perl CGI, font color in a table

by lightoverhead (Monk)
on Feb 28, 2012 at 05:29 UTC ( #956583=perlquestion: print w/ replies, xml ) Need Help??
lightoverhead has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks

I have tried to write a cgi script which includes printing a table like field

one line code I have is:

 td (escapeHTML("This is a required field"))

How can change the color and font of this sentence?

I have tried to search the CGI online doc, but no luck.

Thank you!

Comment on Perl CGI, font color in a table
Download Code
Re: Perl CGI, font color in a table
by oko1 (Deacon) on Feb 28, 2012 at 06:27 UTC

    Question #1 is, why are you doing an 'escapeHTML' on a plain-text string? Unless you're defanging arbitrary input, it's not very useful - and getting rid of it would make your life much easier.

    Having said that, there is a (less-than-pretty) solution: </p?

    print td("font color='red'>".escapeHTML("required")."</font>");
    -- 
    I hate storms, but calms undermine my spirits.
     -- Bernard Moitessier, "The Long Way"

      This works, of course, but I want to make sure that the OP knows that using the font tag is very much deprecated in web design. Use the ideas later in this thread where an inline style (marginally preferable) or a CSS class (much preferable) is used along with an associated definition of the CSS class.

Re: Perl CGI, font color in a table
by Anonymous Monk on Feb 28, 2012 at 07:05 UTC
    http://w3schools.com/html

      I must concur here with the other Anonymous. Using CGI to generate HTML tags is nothing more than a pain in the neck. Just embed the required HTML in your code using here-docs.

      (Generating HTML tags largely makes sense only for form tags where whatever-you-are-using-to-generate-them is supposed to pre-fill the form with possible user input)

      W3Schools may have huge SEO and come up almost any time you Google for a web design search, but please don't use it, nor recommend it. Here's why.

        W3Schools may have huge SEO and come up almost any time you Google for a web design search, but please don't use it, nor recommend it. Here's why.

        SEO? Search-engine-optimization?

        Ok, that w3fools looks interesting, but yeah, I'm going to keep posting the w3 links, their presentation is good, even if the info has some problems, at least they don't complain about urls, and then say "this is lame, we told you" instead of adequately explaining, or providing a link

        at least crockfords page is the 4th result for JavaScript

Re: Perl CGI, font color in a table
by JavaFan (Canon) on Feb 28, 2012 at 07:14 UTC
    Untested:
    td ({-style=>"foreground:red"}, escapeHTML("This is a required field") +);
    The HTML shortcuts take an optional first argument, a hashref with the elements attributes.

    Or you could do:

    td (span ({-class=>"required_field"}, escapeHTML("This is a required f +ield")));
    And use a style sheet to colour spans of class required_field red. Or you could give the table cell a class (or id) attribute.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://956583]
Approved by oko1
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2014-07-28 05:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (186 votes), past polls