thrasha Posted April 23, 2004 Posted April 23, 2004 Hello Everyone! This is my first post ever, I have been reading thru these forums for a few months and have found that most of any problems I have had were answered here so I appreciate all the help from all of you. I now am at the point where I cannot figure something out and I could really use some help. :( I see that there are people searching for a solution to the same problem I have with my site, and I would like to turn this into a contribution to give back to the community that has given me so much. I am designing an automotive parts shop that will have over 10,000 products to start and have organized them into a category scheme like this: Make -> Model -> Year -> Engine -> PRODUCTS I am NOT any sort of programmer, I am a graphic designer with a knack for beating computers into submission. :D I have pieced together code that I found and did a bit of creative hacking and finally come up with a solution to navigate to these products with multiple drop downs. My problem is that I cannot seem to figure out how to get the category descriptions to show up in the boxes once they have been selected. I also cannot get the form to automatically jump to the product listing page once the last option has been chosen. As it is now, the category id numbers show up in the boxes after they have been chosen, and you have to hit a button at the bottom of the page to jump to the product listing page. :angry: I have this on my site as /catalog/vehicle.php but I would also like to turn it into an infobox for easy placement. Please take a look at this code and give me any help and suggestions you might have. <?php require('includes/application_top.php'); echo "Vehicle Search"; //select_box1 if ($HTTP_GET_VARS['vehicle_make_id'] != '') { $select_box1 = '<select name="vehicle_make_id" style="width: 50%"><option value="' . $vehicle_make_id . '" SELECTED>' . $vehicle_make_id . '</option></select>'; } else { $vehicle_make_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name"); $select_box1 = '<select name="vehicle_make_id" onChange="this.form.submit();" size="' . MAX_MAKE_LIST . '" style="width: 50%" >'; if (MAX_MAKE_LIST < 2) { $select_box1 .= '<option value="">Vehicle Make</option>'; } while ($make_values = tep_db_fetch_array($vehicle_make_query)) { $select_box1 .='<option value="' . $make_values['categories_id'] . '"'; $select_box1 .= '>' . $make_values['categories_name'] . '</option>'; } $select_box1 .= "</select>"; $select_box1 .= tep_hide_session_id(); } ////select_box2 if ($vehicle_make_id == '') { } else { if ($HTTP_GET_VARS['vehicle_model_id'] != '') { $select_box2 = '<select name="vehicle_model_id" style="width: 50%"><option value="' . $vehicle_model_id . '" SELECTED>' . $vehicle_model_id . '</option></select>'; } else { $vehicle_model_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . $vehicle_make_id . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name"); $select_box2 = '<select name="vehicle_model_id" onChange="this.form.submit();" size="' . MAX_MODEL_LIST . '" style="width: 50%"'; if ($vehicle_make_id == '') { $select_box2 .= ' disabled>'; } else { $select_box2 .= '>'; } if (MAX_MODEL_LIST < 2) { $select_box2 .= '<option value="">Vehicle Model</option>'; } while ($model_values = tep_db_fetch_array($vehicle_model_query)) { $select_box2 .='<option value="' . $model_values['categories_id'] . '"'; $select_box2 .= '>' . $model_values['categories_name'] . '</option>'; } $select_box2 .= "</select>"; $select_box2 .= tep_hide_session_id(); } } //select_box3 if ($vehicle_model_id == '') { } else { if ($HTTP_GET_VARS['vehicle_year_id'] != '') { $select_box3 = '<select name="vehicle_year_id" style="width: 50%"><option value="' . $vehicle_year_id . '" SELECTED>' . $vehicle_year_id . '</option></select>'; } else { $vehicle_year_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . $vehicle_model_id . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name"); $select_box3 = '<select name="vehicle_year_id" onChange="this.form.submit();" size="' . MAX_YEAR_LIST . '" style="width: 50%"'; if ($vehicle_model_id == '') { $select_box3 .= ' disabled>'; } else { $select_box3 .= '>'; } if (MAX_YEAR_LIST < 2) { $select_box3 .= '<option value="">Vehicle Year</option>'; } while ($year_values = tep_db_fetch_array($vehicle_year_query)) { $select_box3 .='<option value="' . $year_values['categories_id'] . '"'; $select_box3 .= '>' . $year_values['categories_name'] . '</option>'; } $select_box3 .= "</select>"; $select_box3 .= tep_hide_session_id(); } } //select_box4 if ($vehicle_year_id == '') { } else { if ($HTTP_GET_VARS['vehicle_engine_id'] != '') { $select_box4 = '<select name="vehicle_engine_id" style="width: 50%"><option value="' . $vehicle_engine_id . '" SELECTED>' . $vehicle_engine_id . '</option></select>'; } else { $vehicle_engine_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . $vehicle_year_id . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name"); $select_box4 = '<select name="vehicle_engine_id" onChange="this.form.submit();" size="' . MAX_ENGINE_LIST . '" style="width: 50%"'; if ($vehicle_year_id == '') { $select_box4 .= ' disabled>'; } else { $select_box4 .= '>'; } if (MAX_ENGINE_LIST < 2) { $select_box4 .= '<option value="">Vehicle Engine</option>'; } while ($engine_values = tep_db_fetch_array($vehicle_engine_query)) { $select_box4 .='<option value="' . $engine_values['categories_id'] . '"'; $select_box4 .= '>' . $engine_values['categories_name'] . '</option>'; } $select_box4 .= "</select>"; $select_box4 .= tep_hide_session_id(); } } // Display All Drop-downs $cPath = $vehicle_make_id . "_" . $vehicle_model_id . "_" . $vehicle_year_id . "_" . $vehicle_engine_id; print "<form name='vehcle' method='get' action=''>" . $select_box1 . "<br>" . $select_box2 . "<br>" . $select_box3 . "<br>" . $select_box4 . "</form>"; if ($vehicle_engine_id != '') { print "<form name='go' method='get' action='" . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false) . "'><input name='cPath' type='submit' value='" . $cPath . "'>"; } ?> Thanks in advance, -E
safoo Posted April 23, 2004 Posted April 23, 2004 I think this would be one great contribution if you can get it to work. I was having a similar problem for a site that sells printer inks. We would like to be able to choose Brand and printer model using 2 drop downs. This will definitely be a useful contribution.
Billy Posted May 13, 2004 Posted May 13, 2004 Im very intrested in this. Did you get it working? Asus K8V /Amd 3000+ / 1024 DDR400 ~Smokin~
Billy Posted May 13, 2004 Posted May 13, 2004 I had a chance to install this. Im going to take closer look. You code populated the drop down boxes with my inventory. Intresting... Asus K8V /Amd 3000+ / 1024 DDR400 ~Smokin~
Guest Posted May 13, 2004 Posted May 13, 2004 to get it to work as a infobox you will have to create another php file in /catalog/includes/boxes and in that file you just made you need to have a iframe in there to link to the new search php so when the drop downs reload it just reloads the iframe and not the whole page. Pros - Faster Cons - Wont work with older browsers
peterr Posted May 13, 2004 Posted May 13, 2004 Hi, I've done it on a website without frames and no page refreshes, see this for an example: https://web.satlink.com.au/www.impulsegroup.com.au/ Change the 'product type' and the 'colour' options change. It's just a few Javascript arrays, and using the 'onChange' event ......... onChange="JavaScript:updateColourBox();" Peter
katie81 Posted May 13, 2004 Posted May 13, 2004 I also need to do this, peter could you post some more code please? Katie
peterr Posted May 15, 2004 Posted May 15, 2004 Hi, See my post today in this thread: http://www.oscommerce.com/forums/index.php?showtopic=92656 some references to an example of how to do hierarchical dropdowns. Peter
Recommended Posts
Archived
This topic is now archived and is closed to further replies.