I want some help to my problem, i try to get values from a data object from a form field name.
Example i want from fields names to retrieve the value from Data object from current path
1st field is " post " => i want from Data the "post" field
2st field is " recipes[0][recipe_desc_en] " => i want from Data the "recipes->0->recipe_desc_en" field
3st field is " recipes 1 [recipe_desc_en] " => this is not exist from Data object
Here the object data
data: Object
post: "hello world"
recipes: Array[1]
0: Object
recipe_desc_en: "t1"
1: Object
recipe_desc_en: "t2"
here the form
<form>
<input name='post'/>
<input name='recipes[0][recipe_desc_en]'/>
<input name='recipes[1][recipe_desc_en]'/>
</form>
here my starting code
$('input', form).each(function () {
var val = data.data[$(this).data("name")];
console.log(val);
//field post working
//field recipes[0][recipe_desc_en] not working
});
Here the object data
Instead of recipes[0][recipe_desc_en] , try recipes[0].recipe_desc_en
The data recipes looks like an array of objects, so using "." is how you would access that attribute.
Let me know!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.