Quote:
if ($search == 1){
$sql = "select ro.name roname, i.name iname from rooms ro, items i where
".($productItems?"i.id = '$productItems' and " : '')."
ro.id = '$productRoom'";
$s1 = $db->select($sql);
$sql="
select
distinct p.id as id, p.name as pname, p.code as code, p.price, i.name, ra.name, ro.name, p.pic_preview as ppicpreview
from
products as p,
items as i,
ranges as ra,
rooms as ro
where
p.item_id = i.id
and
p.room_id = ro.id
and
p.range_id = ra.id
and
ro.id = '$productRoom' and
p.item_id = '$productItems'
";
// echo $sql;
$smarty->assign("s1Room",$s1[0]["roname"]);
$smarty->assign("s1Item",$s1[0]["iname"]);
Here is the javascript
Quote:
<script language="JavaScript">
var items_1=new Array (
'1', 'bookcases',
'16', 'butler tables',
'13', 'coffee tables',
'14', 'hall tables',
'5', 'leather accents',
'12', 'mirrors',
'15', 'side tables',
'8', 'storage and display units',
'9', 'tables',
'10', 'wood accents',
'');
var items_2=new Array (
'1', 'bookcases',
'11', 'chests of drawers',
'6', 'sideboards',
'8', 'storage and display units',
'');
var items_3=new Array (
'1', 'bookcases',
'2', 'chairs',
'13', 'coffee tables',
'14', 'hall tables',
'6', 'sideboards',
'8', 'storage and display units',
'9', 'tables',
'');
var items_4=new Array (
'16', 'butler tables',
'2', 'chairs',
'11', 'chests of drawers',
'13', 'coffee tables',
'17', 'sectionals',
'15', 'side tables',
'7', 'sofas',
'8', 'storage and display units',
'');
var items_5=new Array (
'3', 'home office and entertainment',
'');
var items_6=new Array (
'11', 'chests of drawers',
'');
var items_0=new Array ('');
function freeSelect(sel,dflt){
for(var i=0;sel.options.length>0;i++){
sel.options[0]=null;
}
sel.options[0]=new Option(dflt,'');
}
function changeRoom(form,room)
{
var cb=form.productItems;
freeSelect(cb,'select item');
var items=eval("items_" + room);
for(i=0; i<(items.length-1);i+=2)
{
var opt=new Option(items[i+1],items[i]);
cb.options[cb.options.length]=opt;
}
}
</script>
Here is the form: