Multiple entry guestbook - allows mulitple entries to be added

Sometime there are applications where you wish to update more than one entry in the guestbook.

My current perl script gbook.pl allows the user to append one gbF() per submit.

This page and perl script: gbook_multi.pl appends more than one gbF() per submit. It is not possible to send an array of objects to the perl script. The perl script only gets name=value pairs. Therefore to send an array of objects, you need to structure the name to have a prefix and name. In this case, the prefix is the array_index so the page form has to have fieldnames where the input fields are named prefix_name.

gbook_multi.pl addes a separate entry for each sub form. The fields for each sub form must be named prefixN_userfield1,prefixN_userfield2,prefixN_userfield3,prefixN_userfield4,prefixN_comments
p1_userfield1,p1_userfield2,p1_userfield3,p1_userfield4,p1_comments
p2_userfield1,p2_userfield2,p2_userfield3,p2_userfield4,p2_comments
p3_userfield1,p3_userfield2,p3_userfield3,p3_userfield4,p3_comments
..
p50_userfield1,p50_userfield2,p50_userfield3,p50_userfield4,p50_comments

gbook_multi.pl stores all the name=value pairs in an associative array. It also stores the prefixes in an associative array. When it writes the gbF() functions, it itterates through the sorted prefixes and writes a gbF() for each prefix.

This form has a standard set of userfield1..userfield2,comments and a set of dynamically generated fields, and a set of dynamically generated fields. these are named pre10N_userfield1..pre10N_userfield2,pre10N_comments where pre10N is pre100+N. The prefix can be anything, but is sorted alphabetically before being used to add the data to the guest book.

The standard form

:name
:email
standardForm:-
:userfield1
:userfield2
:userfield3
:userfield4
Please enter any comments:-
Control Fields (Normally hidden):-
guestbook. The form fields are appended to gbookFXXX.js
nextpage - replaces this form
loadnextpage - flag

The dynamic form

dynamic form generated for each entry:-
When you submit this form, only the sections where the checkbox 'Tick this to append this subform to the guestbook' is checked are added to the guestbook.
:name
:email
Now for each gbF( name,email,postedOn,IPaddress,userfield1,userfield2,userfield3,userfield4,comments) in http://ccgi.dougrice.plus.com/gb/gbookFmulti.js add a sub form.
Control Fields (Normally hidden):-
guestbook. The form fields are appended to gbookFXXX.js
nextpage - replaces this form
loadnextpage - flag
update Log.

gbook_multi.pl source code

You may need to refresh this page to see the latest updates.