[Javascript] action="insert"

David Dorward david at dorward.me.uk
Fri Feb 10 08:30:12 CST 2006


On Fri, Feb 10, 2006 at 09:21:57AM -0500, Shawn Milo wrote:
>    However, do you have a more elegant solution to repopulating the form than
>    the method I mentioned in my earlier e-mail?

Use or write an abstraction layer for generating the forms.

Have a data structure that represents the fields in a standard way and
lets you tie in validation routines and default values to it.

Such a structure in Perl might look something like this:

e.g.

[ 
  {
    type => 'text',
    name => 'myTextField',
    validation => \&myValidationSubroutine,
  },
  {
    type => 'select',
    name => 'mySelectField',
    validation => \&myOtherValidationSubroutine,
    options => [
       { value => 1, text => 'someText', default => 1 },
       { value => 2, text => 'Different text', },
       { value => 3, text => 'Yet more text', },
    ]
  },
]

Then do something along the lines of:

  Form data submitted?
    Yes? Is it valid?
      Yes? Process it
      No? Generate form
    No? Generate form

-- 
David Dorward                                      http://dorward.me.uk




More information about the Javascript mailing list