Take a look at Eric's response.  Except I think it should use name
instead of id:

parms[this.name] = this.value;



On 8/28/07, bweaverusenet <[EMAIL PROTECTED]> wrote:
>
> Okay, thanks.
>
> But I get the same error with $.extend( parms, {this.id :
> this.value } );
>
>    missing : after property id
>
> Hmmm...
>
> On Aug 28, 3:30 am, Wizzud <[EMAIL PROTECTED]> wrote:
> > Use...
> >
> > $.extend( parms, {this.id : this.value } ); // extends parms with the
> > subsequent objects
> >
> > The merge() method is for arrays, whereas parms and {this.id : this.value}
> > are both objects, which is why you are getting the error.
> >
> >
> >
> > bweaverusenet wrote:
> >
> > > Hi. What is the voodoo to build an array for a JSON submit from a
> > > bunch of form fields?
> >
> > > Okay, I'm building the form dynamically from the fields in a mysql DB,
> > > with input/@id set to the field name.
> >
> > > The following naive approach doesn't work, but will give you an idea
> > > of how I'm grabbing what I want to do. It definitely doesn't like the
> > > $.merge( parms, {this.id : this.value }) The error is "missing : after
> > > property id"...
> >
> > >   $("form#additem").submit(function(){
> > >    var parms = { cmd:"ADD" };
> > >            $("form#additem//[EMAIL PROTECTED]").each(function(){
> > >                    parms = $.merge( parms, {this.id : this.value } );
> > >            });
> > >            $.getJSON("thiscode.php",parms,function(data){});
> > >     return false;
> > >   });
> >
> > > So, basically I am fishing for the best way to build or add to an
> > > array from an arbitrary form and send into getJSON.
> >
> > > Thanks,
> > > bill
> >
> > --
> > View this message in 
> > context:http://www.nabble.com/Help-serializing-form-to-array-tf4339452s15494....
> > Sent from the JQuery mailing list archive at Nabble.com.
>
>

Reply via email to