我有一个导航div,其中包含一系列$ deals(超链接)。每笔交易都显示在div中,并带有以下行。
echo '<div id="productMenuBar" . class="productMenuBar">';
foreach ($deals as $k => $v)
{
echo "<a href='#{$k}'>{$k}</a>" . ", ";
}
echo '</div>';
所以$ k是指向mainwrapper容器的超链接,它包含一个标题(nike,addidas,puma等)和包含一个或多个实际产品交易的较小div包。
foreach ($deals as $k => $v)
{
echo '<div id="mainwrapper">';
echo '<a id="'.$k.'">' . '<h2>'.strtoupper(str_replace("_", " ",($k))).' ' . 'Promotion'.'</h2>';
foreach ($v as $key => $val)
{
if ($val['id'] =="02") //01 for horizontal 02 for vertical
{
echo "<div id=\"wrapper1\"><img class=\"deallogo\" src=\"".$val['logo']."\"><div class=\"dealstitle\">".$val['productTitle']."</div>";
echo "<div class=\"vcontainer\"><img class=\"vertical-img\" src=\"".$val['productImage']."\"><div class=\"vdescription\">".$val['productDescription']."</div><div class=\"vpricing\"><div class=\"vrrp\">".$val['rrp']."<div class=\"vsalesprice\">".$val['salePrice']."</div></div></div></div></div>";
}
else
{
echo "<div id=\"lwrapper1\"><img class=\"deallogo\" src=\"".$val['logo']."\"><div class=\"dealstitle\">".$val['productTitle']."</div>";
echo "<div class=\"dealscontainer\"><img class=\"horizontal-img\" src=\"".$val['productImage']."\"><div class=\"dealsdescription\">".$val['productDescription']."</div><div class=\"dealspricing\"><div class=\"rrp\">".$val['rrp']."</div><div class=\"salesprice\">".$val['salePrice']."</div></div></div></div>";
}
}
echo "</div>";
}
交易本身正在从多维数组中拉出来:
<?php
$deals = array (
"nike" => array (
array( all deal 1 info in here),
array( all deal 2 info in here),
array( all deal 3 info in here)),
"puma" = array(
array( all deal 1 info in here),
array( all deal 2 info in here),
array( all deal 3 info in here)),
"addidas" = array(
array( all deal 1 info in here),
array( all deal 2 info in here),
array( all deal 3 info in here)),
);
问题是阵列变得越来越大,它们都显示在一页上。这意味着当您单击导航div中的链接时,它可以从页面跳转到目标交易。我想要做的是在点击导航div中的品牌名称后加载特定的交易(例如只有nike,或者只有美洲狮,或者只有addidas),并且只将那些交易从数组加载到mainwrapper div中。我假设这将涉及一些javascript,以及某种onClick行为,但我不知道从哪里开始?不幸的是,由于内部原因,我无法使用JQuery !!
任何帮助都非常感激。
Volterony