我创建了一个available_categories({类别:外套和夹克})对象和另一个对象category_names_for_display({coatsand-jackets:外套和夹克})对象。
目的是使用available_categories循环中的“键”(外套和夹克),从第二个对象获取category_name_for_display(外套和夹克)。
// build array of available categories
var obj = available_categories.find(o=>o.category === cat);
if (!(obj) && cat && cat.length > 0) {
available_categories.push({
category: cat
});
}
//console.log('ac=' + available_categories);
// build array of category_names_for_display
var obj = category_names_for_display.find(o=>o.cat === category_name_for_display);
if (!obj && cat && cat.length > 0 && category_name_for_display) {
console.log('cat = ' + cat + 'cnfd= ' + category_name_for_display);
var arr = {};
arr[cat] = category_name_for_display;
category_names_for_display.push(arr);
new_var = category_names_for_display['cat'];
console.log('this ' + new_var);
}
if (available_categories.length > 0) {
//loop through the array to output more data
$.each(available_categories, function(k , v)
{
$.each(this, function(k , v)
{
var checked_status = '';
var selected_option_number = '';
var undo_label = '';
console.log('k= ' + k + 'V= ' + v);
// here is where I have something wrong :(
var catego = category_names_for_display['v'];
}
}
}
我只是让控制台显示未定义的值。我需要category_name_for_display是外套和夹克。
答案 0 :(得分:0)
只需尝试创建一个对象并进行推送。
SELECT DDM_ZIP,
MAX( TT_PAD_ZIP ) AS TT_PAD_ZIP
FROM table1 t1
INNER JOIN
table2 t2
ON t1.ddm_zip LIKE t2.tt_pad_zip || '%'
GROUP BY DDM_ZIP
答案 1 :(得分:0)
<form id="sample-form" action="url" method="post">
<input type="hidden" name="params"/>
<button type="submit">Submit</button>
</form>
是category_names_for_display
,错误是您试图以array
的身份访问category_names_for_display
您可以如下所示修改代码,以使object
存储核心内容
var catego