-1

this is my serializeArray.I want get only these 2 push attributes only.other elements in form don't necessary. how to remove others and only keeps these two push values(Attributes and Actions)

 var a = this.serializeArray();
                a.push({name: "Attributes", value:RuleConfigs.attributeContainers});
                a.push({name: "Actions", value:RuleConfigs.actionsContainers});
                $.each(a, function() {
                    if (o[this.name] !== undefined) {
                        if (!o[this.name].push) {
                            o[this.name] = [o[this.name]];
                        }
                        o[this.name].push(this.value || '');
                    } else {
                        o[this.name] = this.value || '';
                    }
                });
                return o;
            };

this is where I call it.

var option=$('form').serializearray();
SashaAlex
  • 47
  • 1
  • 15
  • Your question is not very clear. What is that you want to achieve? – void Mar 07 '18 at 06:42
  • my form has many fields ex-: name,address,attributes,actions likewise. I want to keep these attributes and actions values in json array. but I don't need name and address. how can I remove name and address from that array? – SashaAlex Mar 07 '18 at 06:46

1 Answers1

0

I think you may looking for this

 var result =[];
 a.map(function(item){
     if(item.Name = 'Attribute' ||  item.Name = 'Actions' ) 
         result.push(item);
 })
 console.log(result);
Jaydip Jadhav
  • 12,179
  • 6
  • 24
  • 40