Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Dynamic Filtered Drop-Down Choice Fields

Go to End

5 Posts   2447 Views


Community Member, 349 Posts

30 December 2009 at 5:02am

Have tried to make the form with user forms and script search.js jusing code:


<script type="text/javascript" charset="utf-8">
            function FilterModels() {
                var makeslist = document.getElementById('makes');
                var modelslist = document.getElementById('models');
                var make_id = makeslist.options[makeslist.selectedIndex].value;
                var modelstxt = new Array();
                modelstxt[1] = "1\tEscort\n2\tTaurus";
                modelstxt[2] = "1\tAltima\n2\tMaxima";
                var models = modelstxt[make_id].split("\n");
                for (var count = modelslist.options.length-1; count >-1; count--){
                    modelslist.options[count] = null;
                for (i=0; i<models.length; i++){
                    var modelvals = models.split("\t");
                    var option = new Option(modelvals[1], modelvals[2], false, false);
                    modelslist.options[modelslist.length] = option;

For the userforms i used html block for manufacturer with code:

<select name="makes" onchange="FilterModels()" id="makes">
                <option value="1">Ford</option>
                <option value="2">Nissan</option>

and for html bloxk model this code:

<select name="models" id="models">
                <option>Choose Make</option>

But when i submit the query it gives blank fields how i can fix it.

the tutorial can be fond here:


Community Member, 349 Posts

30 December 2009 at 9:08am

Or is there a possible way to make it like Simple ContactPage with dropdowns that have value. in userforms when u use the dropdownfield it only have role option name .but no name and value.


Community Member, 349 Posts

30 December 2009 at 9:13am

As i understand i need to write somewhere code that posts the selected field but how to do it i dont understand.


Community Member, 545 Posts

1 January 2010 at 5:53am

Well if you just want to fully populate all the drop downs and then filter them you could always jQuery the whole thing to do reveal the various drop down and options. Otherwise you'll have to create a custom form functions in your page controller that populates the first list and on select refreshes the page and populates the next next list. (There's a multi page form tutorial somewhere) Personally I find the jQuery option easier but you'll lose fallback for people that don't have Javascript enabled.


Community Member, 2 Posts

3 May 2012 at 11:47pm

Try out the FilteredDropdownSet from DataObjectManager.