josef,

Just generate the form in pure Perl!

Each time your click to 'add/edit/delete' the entire form data will be sent to your cgi script. Use Perl to update and send the updated form back to the browser. When the final form is complete have a button to 'SAVE' the contents of the form, and at that time also save the updated information to your database.

This is personal preference, but use a hash to save the data, so that fields of the form are like 'field1', 'field2', etc. This allows you to reformat the fields each time the form is sent. You need the number (1..n) to maintain the order of the data.

use strict; my $fields = ""; # input from web form my $sep = chr(254); # something unique could be '%%%' need to up +date form my $text = ""; # html document ( could be read from file ) # on return just send to browser my %TWORK = (); # Processed fields from form Template(\$text,\%TWORK,$sep); print qq|Content-type: text/html\r\n\r\n $text \r\n\r\n|; sub Template { my $text = shift; my $hash = shift; my $sep = shift; $$text =~ s{ $sep ( .*? ) $sep } { exists( $hash->{$1} ) ? $hash->{$1} : "" }gsex; }

I can't take credit for the 'sub', I think I found it on PM, but what a great tool to add to your saved scripts. I use this tool whenever I don't know how big the form will be, and it just keeps on working. You need to add more code to get this working, but hopefully you'll have a good start now.

Good Luck

"Well done is better than well said." - Benjamin Franklin


In reply to Re: Save data from a dynamic HTML table into database by flexvault
in thread Save data from a dynamic HTML table into database by josef

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.