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

CGI PERL Help required

by ghosh123 (Scribe)
on May 08, 2012 at 06:05 UTC ( #969378=perlquestion: print w/ replies, xml ) Need Help??
ghosh123 has asked for the wisdom of the Perl Monks concerning the following question:


Hi Monk,
I have a cgi script. Where I have some code like below :

my $q = new CGI ; #a cgi object print $q->h3("Process"); print $q->html("Steps"); print qq{<FONT SIZE=-1><I>(Click on the hyperlinks in the 'task' colum +n to see further information on methods [if available])</I></FONT><BR +>\n}; print qq{<FONT SIZE=-1><I>(Note: Hyperlinks to the <B>Command/Method +</B> log files will not work on windows)</I></FONT><BR>\n}; print qq{<TABLE BORDER=1 ><TR BGCOLOR="#D0D0D0"> <TH ALIGN=LEFT>Task</TH><TH ALIGN=LEFT>Command</TH><TH ALIGN=LEFT> +Method</TH><TH ALIGN=LEFT>Status</TH><TH ALIGN=LEFT>Task version</TH><TH ALIGN=LE +FT>Tool version</TH><TH ALIGN=LEFT>Last changed</TH><TH ALIGN=LEFT>Comments</TH></TR> \n } +;


Now how can I include this following javascript code in that script. I need to know the syntax Thanks in advance.

<script type="text/javascript" src="http://code.jquery.com/jquery-1.7. +2.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('TABLE:has(th:contains("Status"))').attr('id','maintab'); $('th:contains("Status")').html('<select id="your_answer" name="your_a +nswer" style="margin-bottom:5px"><option value="showAll">showAll</opt +ion><option value="onlyValidStatus">onlyValidStatus</option></select> +<br />Status'); $('#maintab td').each(function(){ if($(this).is(':first-child') && $(this).attr('rowspan')=='undefined') +{ $(this).css('background-color','Red'); $(this).parent().addClass('hid'); } if($(this).is(':nth-child(2)') && $(this).find('a').length==0){ $(this).parent().addClass('hid'); /* if you don't want not valid rows to be colorized remove the two lines below or just comment these lines */ $(this).css('background-color','#f5f5f5'); $(this).siblings().css('background-color','#f5f5f5'); } }); $('#your_answer').change(function(){ if($(this).val()=='onlyValidStatus'){$('.hid').css('display','none');} if($(this).val()=='showAll'){$('.hid').css('display','TABLE-row');} $(this).blur(); }); }); </script>

Comment on CGI PERL Help required
Select or Download Code
Re: CGI PERL Help required
by marto (Chancellor) on May 08, 2012 at 07:04 UTC

    Consider using a template module such as HTML::Template to separate your Perl code and your HTML,JavaScript and CSS.

Re: CGI PERL Help required
by Anonymous Monk on May 08, 2012 at 07:34 UTC

    Now how can I include this following javascript code in that script. I need to know the syntax Thanks in advance.

    Template, here docs, or double quoted string, see Re: Quote and Quote-like Operators / Quote and Quote-like Operators

    perl -MData::Dump -MFile::Slurp -e " dd scalar read_file shift, { qw/ binmode :raw / }; " input.txt > input_txt_as_perl.pl

    Also, see How do I compose an effective node title? as "CGI PERL Help required" is four stop words , things we know simply because you asked a perlquestion (perl help required) or are tangential to the problem (cgi)

    You had already written Now how can I include this following javascript code in that script. I need to know the syntax Thanks in advance. and that is a pretty effective title: Syntax to include javascript

    Syntax to include javascript -> Howto Include JavaScript to CGI.pm Script

    The question discusses using interpolating heredocs (double quotes)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2014-04-17 23:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (459 votes), past polls