【发布时间】:2017-02-17 08:15:20
【问题描述】:
我的产品配置器有一个下拉菜单,我可以在其中选择产品。所选产品具有附加信息(是或否),在选择相应产品时会显示。产品配置器有多种产品可供选择。
如果其中一个产品有附加信息“否”,那么最后的消息是“否”。
如果我现在选择信息从“否”变为“是”的产品,那么最终消息也应更改为“是”而不刷新页面。
选择框代码如下:
<select name="<?php echo $ot['option_type']; ?>">
<?php foreach ($ot['gp_child'] as $key => $child) { $child_id = $child['child_id']; ?>
<option value="<?php echo $child_id; ?>" id="<?php echo $ot['option_type'] . '-' . $child_id; ?>" data-hide="<?php echo $child['child_to_hide']; ?>"><?php echo $child['name']; ?></option>
<?php } ?>
</select>
我要显示的最终消息是:
<?php if ($child['info'][$field_name] == 'No') { ?>
<h5>Diese Produktekonfiguration ist für den CH-Strassenverkehr Zugelassen: <span class="red">No</span></h5>
<?php } else { ?>
<h5>Diese Produktekonfiguration ist für den CH-Strassenverkehr Zugelassen: <span class="green">Yes</span></h5>
<?php } ?>
这适用于初始选择的产品,但是当我更改下拉列表中的值时当然不会改变。我需要添加什么才能使其正常工作?
附加信息 - 如果我在选择框中选择不同的值,则以下字段中的值也会更新:
<?php foreach ($gp_child_info as $field_name => $field_text) if($child['info'][$field_name]) { ?>
<div><?php echo $field_text; ?>: <?php echo $child['info'][$field_name]; ?></div>
<?php } ?>
此字段 $child['info'][$field_name] 包含应触发最终消息的是/否值。
最多有 5 行带有用于选择产品的下拉菜单,每行在 $child['info'][$field_name] 字段中都有值是/否。因此,只要其中一行的值为“No”,最终消息也是“No”。
结果来自 print_r($ot['gp_child']);
Array ( [53] => Array ( [child_id] => 53 [info] => Array ( [product_id] => 53 [gp_parent_id] => 0 [name] => abart [description] => [meta_title ] => test [meta_description] => [meta_keyword] => [tag] => 1234ZV [model] => test [sku] => Yes [upc] => [ean] => [ jan] => [isbn] => [mpn] => [location] => [quantity] => -1 [delivery_days] => 14 [stock_status] => Nicht an Lager [image] => 目录/汽车标志/abarth.png [manufacturer_id] => [manufacturer] => [price] => 100.0000 [special] => [reward] => [points] => 0 [tax_class_id] => 0 [date_available] => 2017-02 -10 [体重] => 0.00kg [weight_class_id] => 1 [length] => 0.00cm [width] => 0.00cm [height] => 0.00cm [length_class_id] => 1 [subtract] => 1 [rating ] => 0 [评论] => 0 [最低] => 1 [排序顺序] => 1 [状态] => 1 [添加日期] => 2017-02-15 14:30:33 [日期修改] => 2017- 02-17 17:17:22 [查看] => 42 [库存] => Nicht an Lager ) [image] => Array ( [popup] => http://2302.speedone.ch/image/cache/catalog/car-logo/abarth-600x400.png [thumb] => http://2302.speedone.ch/image/cache/catalog/car-logo/abarth-50x50.png [swap] = > http://2302.speedone.ch/image/cache/catalog/car-logo/abarth-50x50.png ) [na me] => abart [attributes] => Array ( ) [price] => CHF 100.00 [special] => [tax] => CHF 100.00 [nocart] => [child_to_hide] => ) )
最后触发 Yes/No 消息的值是 [SKU]
【问题讨论】:
-
你有没有为此尝试过任何javascript或jquery?