Defining a record in multitasking html form

In html form I am showing multiple records from table ready to be updated.

Right now I'm using: name=<column-name>_<pk-id> value=<value>

for fields. Then, in my python-script, I go for:

for key in form.keys():
    if key.startswith('<name-A>_'):
        update <table> set <name-A> = <value> where pk=<pk-id>
    if key.startswith('<name-B>_'):
        update <table> set <name-B> = <value> where pk=<pk-id>

      

Is there a more "organic" way to handle multitasking forms?

+1


source to share


1 answer


In java applications, this is a common JSONify name.

<input name="records[pk].fieldName"/>

      



pk

is the primary key of the row and fieldName

field. Of course, most frameworks handle this transparently. Each record ends up as an instance of a class with a property for each field, all of which are placed in a list called "records". You may need to write an interpreter of some kind, but it shouldn't be too difficult.

+1


source







All Articles