Reputation: 991
I get form input elements as follow using jquery for further processing.
var ctrls = $('#frmUserMst').serializeArray();
Occasionally i need to add some extra info into this ctrl Array. How do i do this as
it does not support push()
or add()
method.
This is a requirement in VS2008 MVC2 project.
Further info:
As disabled controls are not populated in the serializeArray()
output, i need to add them manualy.
Any help is appreciated.
Upvotes: 1
Views: 2050
Reputation: 95031
.serializeArray
outputs an array of objects. Each object has two keys: name
and value
. name
represents the input name, and value
represents the input value. Therefore, you can add another item to the array by adding another object to the array that matches the other objects.
var ctrls = $("#frmUserMst").serializeArray();
ctrls.push({
"name": "myinputname",
"value": "myinputvalue"
});
The input doesn't have to exist for you to add a value to that array.
Upvotes: 2