Hi all, I have a cgi script which prints data into a table. However, i have been asked to have a hover effect which would highlight the entire row. This works fine with Firefox but naturally falls down with IE without javascript. Here the problem lays: Testing with html and js only i have a working html page. The javascript code needs to go after the table to work. But how can i call the script in cgi after the table is printed?
use CGI qw(:standard); print header(); print start_html( -title=>'KEGG Connection', -style=>{-src=>'style.css'}, -script=>{-language=>'JavaScript', -src=>'row.js'} # +##this does not work ); perl code to get data print <<EOF; <table> <tr><th>KEGG Entry</th><th>KEGG Glycan Composition</th></tr> EOF more perl print <<EOF; <tr><td><a href="http://">$1</a></td><td>$2</td></tr> EOF
In theory javascript should go here??
print '<script language="javascript">'; var rows = document.getElementsByTagName('tr'); for (var i = 0; i < rows.length; i++) { rows[i].onmouseover = function() { this.className += 'hilite'; } rows[i].onmouseout = function() { this.className = this.className.replace('hilite', ''); } } print "</script>";
Any suggestions please? I havent included the css file, simply because this works in html file? hilite corresponds to the css entry. Thanks

In reply to CGI combining javascript by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.