here's the code what works for me. Its probably not the most beautofull but it works.
Code:
//================dynamic dropdownlist for car_brand and car_model===============================
$page = $_GET['page'];
$product_type = $_GET['product_type'];
$cpath = $_GET['cPath'];
$pID = $_GET['pID'];
$action = "new_product";
$hrefNewCar = "product_car.php?product_type=" . $product_type . "&cPath=" . $cPath . "&action=" . $action;
list($hrefNC1, $hrefNC2, $hrefNC3, $hrefNC4) = split('[_]', $hrefNewCar);
$hrefChangeCar = "product_car.php?page=" . $page . "&product_type=" . $product_type . "&cPath=" . $cPath . "&pID=" . $pID . "&action=" . $action;
list($hrefCC1, $hrefCC2, $hrefCC3, $hrefCC4) = split('[_]', $hrefChangeCar);
echo <<<END
<table>
<tr>
<td class="main">
END;
echo TEXT_PRODUCTS_CAR_BRAND;
echo <<<END
</td>
<td class="main">
END;
echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ';
if (isset($page))
{
echo <<<END
<select STYLE="width: 115px;font-size:80%;" onchange='document.location.href="$hrefCC1"+"_"+"$hrefCC2"+"_"+"$hrefCC3"+"_"+"$hrefCC4"+"&car_brand_id="+this.options[this.selectedIndex].value;'>
END;
if (isset($_GET['car_brand_id'])) //Get car_brand_id for taking it into the car_brand dropdownlist as first select (href link from car_brand dropdownlist)
{
$car_brand_id = $_GET['car_brand_id'];
echo "<option value=\"$car_brand_id\">$car_brand_array[$car_brand_id]</option>";
$pInfo->car_brand_id = $car_brand_id; //used by car_brand dropdown
for ($i = 0; $i < sizeof($car_brand_array); ++$i)
{
echo "<option value=\"$i\">$car_brand_array[$i]</option>";
}
}
else //Get car_brand_id for taking it into the car_brand dropdownlist as first select (from hidden_field preview_info)
{
$car_brand_id = $pInfo->car_brand_id; //used by car_brand dropdown
echo "<option value=\"$car_brand_id\">$car_brand_array[$car_brand_id]</option>";
for ($i = 0; $i < sizeof($car_brand_array); ++$i)
{
echo "<option value=\"$i\">$car_brand_array[$i]</option>";
}
}
}
else
{
echo <<<END
<select STYLE="width: 115px;font-size:80%;" onchange='document.location.href="$hrefNC1"+"_"+"$hrefNC2"+"_"+"$hrefNC3"+"_"+"$hrefNC4"+"&car_brand_id="+this.options[this.selectedIndex].value;'>
END;
if (isset($pInfo->car_brand_id)) //Get car_brand_id for taking it into the car_brand dropdownlist as first select (from hidden_field preview_info)
{
$car_brand_id = $pInfo->car_brand_id; //used by car_brand dropdown
echo "<option value=\"$car_brand_id\">$car_brand_array[$car_brand_id]</option>";
for ($i = 0; $i < sizeof($car_brand_array); ++$i)
{
echo "<option value=\"$i\">$car_brand_array[$i]</option>";
}
}
elseif (isset($_GET['car_brand_id'])) //Get car_brand_id for taking it into the car_brand dropdownlist as first select (href link from car_brand dropdownlist)
{
$car_brand_id = $_GET['car_brand_id'];
echo "<option value=\"$car_brand_id\">$car_brand_array[$car_brand_id]</option>";
$pInfo->car_brand_id = $car_brand_id; //used by car_brand dropdown
for ($i = 0; $i < sizeof($car_brand_array); ++$i)
{
echo "<option value=\"$i\">$car_brand_array[$i]</option>";
}
}
else //make car_brand dropdownlist for the first time without an id for the brand dropdownlist
{
$pInfo->car_brand_id = 0; //car_brand_id is set, because there was no brand selection from collect_info
for ($i = 0; $i < sizeof($car_brand_array); ++$i)
{
echo "<option value=\"$i\">$car_brand_array[$i]</option>";
}
}
}
echo zen_draw_hidden_field('car_brand_id', $pInfo->car_brand_id);//passthrough of car_brand_id from collect_info to preview_info and vica versa
echo <<<END
</select></td></tr>
END;
//if (isset($pInfo->car_brand_id)) //when car_brand_id is set, make a model array with the specific brand_id
if ($pInfo->car_brand_id == 0) //when car_brand_id is set, make a model array with the specific brand_id
{
$car_model = $db->Execute("select car_model_id, car_model from CAR_MODEL where car_brand_id = 0 order by car_model");
$car_model_array[] = array('id' => 0, 'text' => TEXT_NONE);
}
else
{
$car_model = $db->Execute("select car_model_id, car_model from CAR_MODEL where car_brand_id = " . $pInfo->car_brand_id . " order by car_model");
$car_model_array[] = array('id' => 0, 'text' => TEXT_NONE);
while (!$car_model->EOF)
{
$car_model_array[] = array('id' => $car_model->fields[car_model_id], 'text' => $car_model->fields[car_model]);
$car_model->MoveNext();
}
}
//============== car_model dropdownlist==========================================================================
?>
<tr>
<td class="main">
<?php echo constant("TEXT_PRODUCTS_CAR_MODEL"); ?>
</td>
<td class="main">
<?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_pull_down_menu('car_model_id', $car_model_array, $pInfo->car_model_id);?>
</td>
</tr>
<?php
//==================================================================================================================
//================END dynamic dropdownlist for car_brand and car_model==============================================