[whatwg] additional key attribute in form field

Dnia pi?tek, 6 lipca 2007 13:32, Alexander napisa?:
> Greetings,
>
> i wonder why there's still no a special 'key' attribute for every form
> field implemented.
>
> Let's say I have rendered table from query result and one column could be
> updateable via text field. And let's say record id field is
> uniqueidentifier (not integer). I'd like to write the following:
>
> <form ...>
> !--- Loop query results ---!
> <input type="text" key="{id_value_here}" name="quantity" value="">
> ....
> <input type="text" key="{id_value_here}" name="quantity" value="">
> !--- End of loop ---!
> </form>
>
> and
>
> when submitting the form and checking results on server, I'd like to know
> the 'owner' of every quantity field:
>
> !--- loop via quantity fields ---!
> if (quantity.key == 'XXXXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX') { ... }
> !--- end of loop ---!
>
> Regards,
> Alexander.

1. Your code is old-fashioned: the identifier should be used instead of the 
name.
2. The identifier should be unique throughout the document so your code will 
be ill-formed.

If I understand your intention correctly, you want to submit an entire table 
instead of just one record a time; HTML forms clearly were not designed with 
that application in mind.  I think you would be better off by performing an 
internal query on the client side---where you can refer to the form fields by 
numeric index rather than by identifier---and reformatting it to JSON before 
submission.  If this is impossible, you could make a round trip to the server 
for each record.  My experience shows that it is often the case with current 
implementations.

Chris

Received on Saturday, 7 July 2007 08:40:52 UTC