Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2023-06-06 12:34 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (26 votes). Check out past polls.