仅在选择组合时显示prestashop可自定义文本

时间:2014-03-22 01:48:07

标签: prestashop

我有一个有2种组合的商店。是和否。我在产品中添加了可自定义的文本,但我希望仅当选择“是”时才会显示此文本区域。有人可以帮我这么做吗?

谢谢!

编辑:

感谢您的回复。我的代码现在看起来像这样:

//init the serialScroll for thumbs
$('#thumbs_list').serialScroll({
    items:'li:visible',
    prev:'#view_scroll_left',
    next:'#view_scroll_right',
    axis:'x',
    offset:0,
    start:0,
    stop:true,
    onBefore:serialScrollFixLock,
    duration:700,
    step: 2,
    lazy: true,
    lock: false,
    force:false,
    cycle:false
});

$('#group_22').change(function() {
$('.idTab10').toggle();

});

可悲的是它不起作用。什么都没发生。 (是)选择ID为22.请告知。

1 个答案:

答案 0 :(得分:0)

我建议你用jQuery做到这一点。

您只需要修改文件/themes/your_theme/js/product.js
在此文件中,搜索:

$(document).ready(function()
{
    ...
});

最后,添加以下代码:

toggleCustomization(); // We launch the function on page load
$('#group_4').change(function() { // We launch the function when select is changed
    toggleCustomization();
});

关闭$(document).ready(function()后,立即添加此函数:

function toggleCustomization() { // Hide or Show Customization Form and Tab
    if($('#group_4').val() == '23') { // We hide Customization Form and Tab if No is selected
        $('#idTab10').hide();
        $('a[href="#idTab10"]').hide();
    } else { // We show Customization Form and Tab if Yes is selected
        $('#idTab10').show();
        $('a[href="#idTab10"]').show();
    }
};

其中:

  • group_4是您的是 - 否选择
  • 的ID
  • idTab10是包含有关自定义字段的所有信息的bloc的ID
  • 23是'否'在您的选择