Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

"Dynamic" HTML Forms, Tracking Data and Trepidation

by mjn (Acolyte)
on Feb 07, 2002 at 18:20 UTC ( #143943=perlquestion: print w/replies, xml ) Need Help??

mjn has asked for the wisdom of the Perl Monks concerning the following question:

I am working on a web form for a client and they would like it to be expandable.

The best way to explain it is this:

Each form will contain billing/contact information and service request information. The service request section is for telecomm additions, modifications, and removals of service. The main problems with the old forms is that you had to submit one request for each, well, request. You could not submit multiple jobs from one form with the same billing and contact information.

So what I would like to do is make the form and associated HTML in perl with So we have the form start out with a default number of request sections (each one containing checkboxes, textfields, whatever) and the number of those request sections is expandable by the user(to be duplicated precisely each time one or more is added). Perhaps there is a text field which they can add a number to and have that modify the form(suggestings on a good way to expand the form are also welcome, I have ideas but there might be something simpler I am missing).

So say we start out with something like this:

My Great Form!

  • Contact Information
  • Billing Information
  • Request

I want to be able to expand it to something like this on the fly:

My Great Form!

  • Contact Information
  • Billing Information
  • Request #1
  • ...
  • Request #N

Great. So the form is expandable.

My questions surrounding this are these:

  • What happens to the data they have already entered into the form? Is there an easy way to repopulate this information into the form fields and expand the form at the same time?
  • How do I (do I need to?) track multiple requests within the form since they will, presumably, have the same name values in the form? Am I going to have problems stomping on variables or should I just rely on the QUERY_STRING and read it in order?

Are there other sources people would recommend or are they techniques anyone here has used to deal with similar issues? I checked Q&A but I didn't find much in the way of helpful information (although Ovid's CGI Course has been quite informative about what /not/ to do).

As always, any advice is much appretiated.


  • Comment on "Dynamic" HTML Forms, Tracking Data and Trepidation

Replies are listed 'Best First'.
Re: "Dynamic" HTML Forms, Tracking Data and Trepidation
by screamingeagle (Curate) on Feb 07, 2002 at 19:18 UTC
    One way to do it would be :
    Design the form so that along with the Contact Information and Billing Information , you have , say, 3 input fields for Requests (say Request1, Request2 and Request3)...keep a submit button after that which says "Add more Requests". (Keep in mind that this submit button is in addition to the default submit button which says "Finished Adding Reuests" or something to that effect ) Now, when the user presses the "Add more Requests" button, the form should save into the database all the information that the user has added so far , and after the data is saved, the form should be loaded again displaying all the saved data in an editable format,ALONG with 1 additional input box for the additional request that the user wants to make...this process can continue till the user presses the "Finished Adding Reuests" button, which ends the process...
    The advantage of this approach is that the user can not only add more requests, but he/she can edit the information previously added and update that information...
    you'll have to write a function which checks whether you need to fire an "UPDATE" SQL statement or an "INSERT" statment... shouldnt be too hard since u can make those checks using the primary keys of the data already entered..
    hope this helps :)
Re: "Dynamic" HTML Forms, Tracking Data and Trepidation
by pitbull3000 (Beadle) on Feb 08, 2002 at 11:55 UTC
    why dont you give javascript and dhtml not a chance? expand your form on the clientside with javascript, so you dont have to bother how the already given information and data has to be handled and you dont have the traffic on your side each time a customer expands the form.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://143943]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2023-01-27 10:26 GMT
Find Nodes?
    Voting Booth?

    No recent polls found