Re: Request for FormData.remove() method

On 18.4.2012 6:50, David Sickmiller wrote:
> Hi,
>
> I must admit I am ignorant of the W3C process for drafting the 
> XMLHttpRequest, but I see that the webpage says to send feedback to 
> this address, so I am writing this email to submit my feedback.
>
> The "new FormData(form)" constructor is an especially handy way to 
> slurp in all the data for a given form.  As the documentation 
> describes, the algorithm for constructing the form data set is quite 
> intricate -- it takes 3 pages to describe.
>
> I have an application where I need to change or remove field values 
> that were received from the user, before they are submitted using an 
> XHR.  (I'm removing cue text from text input fields.)  It would be 
> ideal to call some sort of FormData.remove() (or perhaps 
> "removeAllByName") method.  Unfortunately, no function like that is 
> defined in the FormData interface.  The most obvious alternative is to 
> re-implement the 3-page algorithm to construct the form data set, and 
> then add my application-specific twist.  That's not a simple task to 
> get perfect.
Agreed, being able to work with FormData as an object (setters, getters, 
deleters) would be improvement... so far we only have setters

any get(DOMString name)
method to retrieve FormData value

DOMString name(number index)
to get FormData name at particular index (function could return empty 
string if there is no name at that index),
var i = 0;
while (name = formData.name(i++)) { doSomething(formData.get(name)); }

or maybe even count property to get the number of names

FormData can be useful not only to be sent via XHR, but essentially to 
hold form values easily, e.g. you can have settings form (that you do 
not need to send any where = you do not need to store it or you store it 
in e.g. IndexDb), then get this settings and alter application according 
to this settings... Instead of doing exactly the same, but manually

Brona

Received on Wednesday, 18 April 2012 18:08:42 UTC