【发布时间】:2016-09-30 10:17:42
【问题描述】:
我向 DB 添加了一个新列,用于向 Opencart 中的属性添加描述,我可以轻松地从管理面板添加/编辑描述,但我在 product_form 页面中遇到问题。当我选择属性名称时,我想为每个产品自动添加属性描述。 在 Opencart 中,管理员可以从自动完成框中选择产品的属性,但每次管理员都应该手动添加属性描述。例如属性“黄金”。每次管理员选择属性“黄金”时,他都必须手动添加黄金描述。我想从数据库列'protext'中检索属性描述,以便在管理员时自动填充相关的文本区域。因此,当从输入框中选择“Gold”时,相关文本应出现在相关文本区域中进行描述。
这是我以产品形式编辑的代码,但不起作用。 您的帮助将不胜感激。
function attributeautocomplete(attribute_row) {
$('input[name=\'product_attribute[' + attribute_row + '][name]\']').autocomplete({
'source': function(request, response) {
$.ajax({
url: 'index.php?route=catalog/attribute/autocomplete&token=<?php echo $token; ?>&filter_name=' + encodeURIComponent(request),
dataType: 'json',
success: function(json) {
response($.map(json, function(item) {
return {
category: item.attribute_group,
label: item.name,
label2: item.protext,
value: item.attribute_id
}
}));
}
});
},
'select': function(item) {
$('input[name=\'product_attribute[' + attribute_row + '][name]\']').val(item['label']);
$('input[name=\'product_attribute[' + attribute_row + '][attribute_id]\']').val(item['value']);
$('input[name=\'related\']').val('');
}
$('textarea[name=\'product_attribute[' + attribute_row + '][product_attribute_description][text]\']').autocomplete({
'append': function(item) {
$('textarea[name=\'product_attribute[' + attribute_row + '][product_attribute_description][text]\']').val(item['protext']);
}
});
}
【问题讨论】:
-
这是一个紧迫的问题。您的帮助将不胜感激。
标签: php jquery json textarea opencart