What version of 68 Classifieds are you running? Example: V4.2.1 Developer What template are you using? 3 col Please describe in detail the issue you are having: Im trying to split my category list down into a categories drop down list and a sub cateories drop down list (I only have two levels of categories). I have too many categories so if you are searching or placing an ad the drop down list is huge and runs off the screen. I started in the search.tpl file by modifying the categories drop down an adding another drop down box after it. My problem is that I have no idea how to get the second drop down box to dynamically update depending on what selection is made in the first box. Here is my code Code: <p id="category"> <label for="type">{$smarty.const.LANG_SEARCH_INCAT}{$smarty.const.LANG_COLON}</label> <select name="type" id="type"> <option value=''>{$smarty.const.LANG_SEARCH_ALLCAT}</option> {foreach from=$getcats item=cat} {if $cat.parent_id == 0} <option value="{$cat.id}"{if $type==$cat.id} SELECTED{/if}>{$cat.name}</option> {/if} {/foreach} </select> </p> <p id="subcategory"> <label for="subtype">Sub Category{$smarty.const.LANG_COLON}</label> <select name="subtype" id="subtype"> <option value=''>{$smarty.const.LANG_SEARCH_ALLCAT}</option> {foreach from=$getcats item=cat} {if $cat.parent_id == type} <option value="{$cat.id}"{if $type==$cat.id} SELECTED{/if}>{$cat.name}</option> {/if} {/foreach} </select> </p> Do I use like onSelect Java statements? I know the extra fields do this automatically but it's using like Ajax I think. Thanks! can anyone give me the code i would use to dynamically update the second drop down? P.S have a look iheartwheels.com at my search page to see what I mean and how far ive got (which isnt very far). Many thanks
You can do it with javascript, but you'd have to change the existing javascript to ensure the category chosen still brings up the extra fields. Are your fields the same for all categories?
Yes they could be the same for each category. Having too many categories caused an issue with these drop downs so I changed to using extra fields for all car makes and models while just keeping the very top level categories (however this stops you from being able to use the browse function to browse thorugh makes and models of cars) so im trying to switch back to using categories but without having a HUGE drop down list when you select a category for searching or posting an ad. How would I get javascript to update the second drop down when I select the top level category from the first drop down? Many thanks
The easiest way would be to set its size for amount of options to display: HTML: <select name="type" id="type" size="4">
They could scroll to them, and it would depend on the size you set. Doing it via ajax and php would be complicated, and even then it would required the user to have javascript enabled. If you must do it that way, you might considering contacting a 3rd party developer directly and getting a quote. Another option is to reorganize your categories, grouping them by extra fields instead of sub-categories would probably be the easiest. Then all you have to do is use a parent/child dropdown or a regular dropdown to search. Since they all share the same fields it shouldn't be too much of a problem and it would simplify your categories.
Ok I think I just need to find the right balance maybe have the makes as categories and the models as extra fields. I'll see if anyone is up for a bit of saturday work lol. Thanks for the advice.