Hello all, I've been working on a scheduling system for a client of mine which I will quickly describe: My client will be able to log in to an editor (that's the form this post refers to) and be able to add, delete, or edit appointments. These appointments are stored in an XML file. When one of my client's users comes to the site, they can view a page that dynamically builds a schedule based upon the appointments in the XML file. The part I'm questioning is the editing form.

This will basically be an interactive form. By that, I mean that my client will get this form to appear, then he'll be able to press buttons and type content into the form and then get the same form back but with different information displayed. (If you'd like to see the portion of it I have working now, go here. The username and password are Administrator/schedBuilder - they are case sensitive.)

I've been using HTML::Template for some of the script, such as the login screen, but, as this will be an "interactive" form, I don't see how I can still use HTML::Template. I really need a way to push data into form components and I don't think that can be done with HTML::Template. Perhaps there's a way to use that module that I'm overlooking.

In order to get the functionality that I'm looking for, I've written two different pieces of code that perform the same task, just in different ways. The first one uses various methods from CGI.pm:
#Print the data onto the screen print table({-border=>1}, Tr( td({-valign=>'top'}, table({-border=>1}, Tr(td(center('Days with Appointments:'))), Tr(td(center( $query->scrolling_list( -NAME => "daysList", -VALUES => [keys %calendar], -SIZE => 5, -MULTIPLE => 0,) ) ) ), Tr(td(center( $query->submit({-name=>'dateSelectionButton', -value=>'Dis +play Appts'}) ) ) ) ) ), td({-valign=>'top'}, table({-border=>1}, Tr(td(center('Appointments:'))), Tr(td(center( $query->scrolling_list( -NAME => "apptsList", -VALUES => \@apptTimeList, -SIZE => 5, -MULTIPLE => 0,) ) ) ) ) ) ) );
The second piece of code I've written uses block printing and looks like this:
print <<StartTable; <TABLE BORDER="1"> <TR> <TD VALIGN="top"> <TABLE BORDER="1"> <TR> <TD><CENTER>Days with Appointments:</CENTER></TD> </TR> <TR> <TD><CENTER> StartTable print $query->scrolling_list( -NAME => "daysList", -VALUES => [keys %calendar], -SIZE => 5, -MULTIPLE => 0, ); print <<MidTable; </CENTER></TD> </TR> <TR> <TD><CENTER><INPUT TYPE="SUBMIT" VALUE="Display Appts"></C +ENTER></TD> </TR> </TABLE> </TD> <TD VALIGN="top"> <TABLE BORDER="1"> <TR> <TD><CENTER>Appointments:</CENTER></TD> </TR> <TR> <TD><CENTER> MidTable print $query->scrolling_list( -NAME => "apptsList", -VALUES => \@apptTimeList, -SIZE => 5, -MULTIPLE => 0, ); print <<EndTable; </CENTER></TD> </TR> </TABLE> </TD> </TR> </TABLE> EndTable
As far as I can tell, these two bits of code work identically. The only question I have is which one is going to be easier to maintain. Personally, I'm able to read the second bit easier so I would feel that this would be the easiest to maintain, but so often, I hear monks exclaim "USE CGI.pm!" Is there something I'm missing that would make the first portion of code easier to maintain later?

So I'd like to hear your opinions on which chunk of code would be easier to maintain or, if there's an entirely better way of handling this situation, I'd really like to know. One thing that had occured to me is that maybe this is a case of overkill - perhaps using CSS and JavaScript would be an easier way of accomplishing this task.

Thanks,
- Sherlock

Skepticism is the source of knowledge as much as knowledge is the source of skepticism.

In reply to Interactive Form Creation/Maintenance by Sherlock

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.