Hi Monks!

I am building an application that needs a table row added dynamically, well the code works fine if it is an html file, but I want this html to be inside of a Perl code. The problem is that, there is something that Perl don’t like, I can see it, maybe someone of you had a similar problem like that and could give a hand on this one!

Here is the code and thank you very much!!!


#!/perl/bin/perl.exe use strict; use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); print header(); print <<HTML; <html> <head> <title>Add or Remove Rows Dynamically</title> <script type="text/javascript"> <!-- var count = 1; var nRows = 2; function addRow() { var tBody = document.getElementById('theBody'); var newRow = document.createElement('tr'); var col1 = document.createElement('td'); var col2 = document.createElement('td'); var col3 = document.createElement('td'); var rA = document.createElement('a'); newRow.setAttribute('id', 'n' + count); rA.setAttribute('href', 'javascript:removeRow(\' +n' + count + '\');'); rA.appendChild(document.createTextNode('Remove')); col1.appendChild(document.createTextNode('Col 1 Row ' + + nRows)); col2.appendChild(document.createTextNode('Col 2 Row ' + + nRows)); col3.appendChild(rA); newRow.appendChild(col1); newRow.appendChild(col2); newRow.appendChild(col3); tBody.appendChild(newRow); count++; nRows++; } function removeRow(rowId) { var tBody = document.getElementById('theBody'); tBody.removeChild(document.getElementById(rowId)); nRows--; } --> </script> </head> <body> <table border=1> <tbody id=\"theBody\"> <tr> <td>Policy Number:</td> <td><input type=text name=policy value=\"\"></td> </tr> </tbody> </table> <p><a href="javascript:addRow()">Add Row</a></p> </body> </html> HTML ;

In reply to Perl Generating error on display. 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.