how to create a drill down search menu on a website











up vote
-2
down vote

favorite












I am trying to set up a website (i have used a bootstrap template and made some changes to it). I want a search function on top of the page where you can select a product but then there will be another drop down.



For example one search box, which is a drop down menu will have a list of vehicles; audi bmw and Mercedes. if you select Audi i want the drop down next to it to only show model that belong to the audi range and so on.



Also for forward planning; if a new model vehicle releases for audi how would i then add this to my list?



----------------UPDATE---------------



I managed to do some research and got the code working kind of.
I have incorporated JS in my website. I've got the first drop down to work but the second drop down does not run?






 $('.dropdown')function configureDropDownLists(ddl1,ddl2) {
var Audi = new Array('A1', 'S1', 'RS3');
var BMW = new Array('3 series', '5 series', 'M5');
var Ford = new Array('A Class', 'C Class', 'E class');

switch (ddl1.value) {
case 'Audi':
ddl2.options.length = 0;
for (i = 0; i < Audi.length; i++) {
createOption(ddl2, Audi[i], Audi[i]);
}
break;
case 'BMW':
ddl2.options.length = 0;
for (i = 0; i < BMW.length; i++) {
createOption(ddl2, BMW[i], BMW[i]);
}
break;
case 'Ford':
ddl2.options.length = 0;
for (i = 0; i < Ford.length; i++) {
createOption(ddl2, Ford[i], Ford[i]);
}
break;
default:
ddl2.options.length = 0;
break;
}

}

$('.dropdown2')function createOption(ddl, text, value) {
var opt = document.createElement('option');
opt.value = value;
opt.text = text;
ddl.options.add(opt);
}

    <select class="dropdown" id="ddl" onchange="configureDropDownLists(this,document.getElementById('ddl2'))">
<option value=""></option>
<option value="Audi">Audi</option>
<option value="BMW">BMW</option>
<option value="Ford">Ford</option>
</select>

<select id="ddl2">
</select>












share|improve this question
























  • what you are communicating about is not dropdown menu. it is more or less like a tree view. like in windows explorer. except that you are not asking for a trailing line from the root.
    – vssadineni
    Nov 21 at 13:37










  • And this is not the right place for ideating. Instead work on it and if you have some code and got stuck anyone from 'SO' can help you with it.
    – vssadineni
    Nov 21 at 13:44










  • @HaseebMohammed. Would a dropdown that opened another dropdown be useful, like this: w3schools.com/bootstrap/…
    – user2796515
    Nov 21 at 14:05

















up vote
-2
down vote

favorite












I am trying to set up a website (i have used a bootstrap template and made some changes to it). I want a search function on top of the page where you can select a product but then there will be another drop down.



For example one search box, which is a drop down menu will have a list of vehicles; audi bmw and Mercedes. if you select Audi i want the drop down next to it to only show model that belong to the audi range and so on.



Also for forward planning; if a new model vehicle releases for audi how would i then add this to my list?



----------------UPDATE---------------



I managed to do some research and got the code working kind of.
I have incorporated JS in my website. I've got the first drop down to work but the second drop down does not run?






 $('.dropdown')function configureDropDownLists(ddl1,ddl2) {
var Audi = new Array('A1', 'S1', 'RS3');
var BMW = new Array('3 series', '5 series', 'M5');
var Ford = new Array('A Class', 'C Class', 'E class');

switch (ddl1.value) {
case 'Audi':
ddl2.options.length = 0;
for (i = 0; i < Audi.length; i++) {
createOption(ddl2, Audi[i], Audi[i]);
}
break;
case 'BMW':
ddl2.options.length = 0;
for (i = 0; i < BMW.length; i++) {
createOption(ddl2, BMW[i], BMW[i]);
}
break;
case 'Ford':
ddl2.options.length = 0;
for (i = 0; i < Ford.length; i++) {
createOption(ddl2, Ford[i], Ford[i]);
}
break;
default:
ddl2.options.length = 0;
break;
}

}

$('.dropdown2')function createOption(ddl, text, value) {
var opt = document.createElement('option');
opt.value = value;
opt.text = text;
ddl.options.add(opt);
}

    <select class="dropdown" id="ddl" onchange="configureDropDownLists(this,document.getElementById('ddl2'))">
<option value=""></option>
<option value="Audi">Audi</option>
<option value="BMW">BMW</option>
<option value="Ford">Ford</option>
</select>

<select id="ddl2">
</select>












share|improve this question
























  • what you are communicating about is not dropdown menu. it is more or less like a tree view. like in windows explorer. except that you are not asking for a trailing line from the root.
    – vssadineni
    Nov 21 at 13:37










  • And this is not the right place for ideating. Instead work on it and if you have some code and got stuck anyone from 'SO' can help you with it.
    – vssadineni
    Nov 21 at 13:44










  • @HaseebMohammed. Would a dropdown that opened another dropdown be useful, like this: w3schools.com/bootstrap/…
    – user2796515
    Nov 21 at 14:05















up vote
-2
down vote

favorite









up vote
-2
down vote

favorite











I am trying to set up a website (i have used a bootstrap template and made some changes to it). I want a search function on top of the page where you can select a product but then there will be another drop down.



For example one search box, which is a drop down menu will have a list of vehicles; audi bmw and Mercedes. if you select Audi i want the drop down next to it to only show model that belong to the audi range and so on.



Also for forward planning; if a new model vehicle releases for audi how would i then add this to my list?



----------------UPDATE---------------



I managed to do some research and got the code working kind of.
I have incorporated JS in my website. I've got the first drop down to work but the second drop down does not run?






 $('.dropdown')function configureDropDownLists(ddl1,ddl2) {
var Audi = new Array('A1', 'S1', 'RS3');
var BMW = new Array('3 series', '5 series', 'M5');
var Ford = new Array('A Class', 'C Class', 'E class');

switch (ddl1.value) {
case 'Audi':
ddl2.options.length = 0;
for (i = 0; i < Audi.length; i++) {
createOption(ddl2, Audi[i], Audi[i]);
}
break;
case 'BMW':
ddl2.options.length = 0;
for (i = 0; i < BMW.length; i++) {
createOption(ddl2, BMW[i], BMW[i]);
}
break;
case 'Ford':
ddl2.options.length = 0;
for (i = 0; i < Ford.length; i++) {
createOption(ddl2, Ford[i], Ford[i]);
}
break;
default:
ddl2.options.length = 0;
break;
}

}

$('.dropdown2')function createOption(ddl, text, value) {
var opt = document.createElement('option');
opt.value = value;
opt.text = text;
ddl.options.add(opt);
}

    <select class="dropdown" id="ddl" onchange="configureDropDownLists(this,document.getElementById('ddl2'))">
<option value=""></option>
<option value="Audi">Audi</option>
<option value="BMW">BMW</option>
<option value="Ford">Ford</option>
</select>

<select id="ddl2">
</select>












share|improve this question















I am trying to set up a website (i have used a bootstrap template and made some changes to it). I want a search function on top of the page where you can select a product but then there will be another drop down.



For example one search box, which is a drop down menu will have a list of vehicles; audi bmw and Mercedes. if you select Audi i want the drop down next to it to only show model that belong to the audi range and so on.



Also for forward planning; if a new model vehicle releases for audi how would i then add this to my list?



----------------UPDATE---------------



I managed to do some research and got the code working kind of.
I have incorporated JS in my website. I've got the first drop down to work but the second drop down does not run?






 $('.dropdown')function configureDropDownLists(ddl1,ddl2) {
var Audi = new Array('A1', 'S1', 'RS3');
var BMW = new Array('3 series', '5 series', 'M5');
var Ford = new Array('A Class', 'C Class', 'E class');

switch (ddl1.value) {
case 'Audi':
ddl2.options.length = 0;
for (i = 0; i < Audi.length; i++) {
createOption(ddl2, Audi[i], Audi[i]);
}
break;
case 'BMW':
ddl2.options.length = 0;
for (i = 0; i < BMW.length; i++) {
createOption(ddl2, BMW[i], BMW[i]);
}
break;
case 'Ford':
ddl2.options.length = 0;
for (i = 0; i < Ford.length; i++) {
createOption(ddl2, Ford[i], Ford[i]);
}
break;
default:
ddl2.options.length = 0;
break;
}

}

$('.dropdown2')function createOption(ddl, text, value) {
var opt = document.createElement('option');
opt.value = value;
opt.text = text;
ddl.options.add(opt);
}

    <select class="dropdown" id="ddl" onchange="configureDropDownLists(this,document.getElementById('ddl2'))">
<option value=""></option>
<option value="Audi">Audi</option>
<option value="BMW">BMW</option>
<option value="Ford">Ford</option>
</select>

<select id="ddl2">
</select>








 $('.dropdown')function configureDropDownLists(ddl1,ddl2) {
var Audi = new Array('A1', 'S1', 'RS3');
var BMW = new Array('3 series', '5 series', 'M5');
var Ford = new Array('A Class', 'C Class', 'E class');

switch (ddl1.value) {
case 'Audi':
ddl2.options.length = 0;
for (i = 0; i < Audi.length; i++) {
createOption(ddl2, Audi[i], Audi[i]);
}
break;
case 'BMW':
ddl2.options.length = 0;
for (i = 0; i < BMW.length; i++) {
createOption(ddl2, BMW[i], BMW[i]);
}
break;
case 'Ford':
ddl2.options.length = 0;
for (i = 0; i < Ford.length; i++) {
createOption(ddl2, Ford[i], Ford[i]);
}
break;
default:
ddl2.options.length = 0;
break;
}

}

$('.dropdown2')function createOption(ddl, text, value) {
var opt = document.createElement('option');
opt.value = value;
opt.text = text;
ddl.options.add(opt);
}

    <select class="dropdown" id="ddl" onchange="configureDropDownLists(this,document.getElementById('ddl2'))">
<option value=""></option>
<option value="Audi">Audi</option>
<option value="BMW">BMW</option>
<option value="Ford">Ford</option>
</select>

<select id="ddl2">
</select>





 $('.dropdown')function configureDropDownLists(ddl1,ddl2) {
var Audi = new Array('A1', 'S1', 'RS3');
var BMW = new Array('3 series', '5 series', 'M5');
var Ford = new Array('A Class', 'C Class', 'E class');

switch (ddl1.value) {
case 'Audi':
ddl2.options.length = 0;
for (i = 0; i < Audi.length; i++) {
createOption(ddl2, Audi[i], Audi[i]);
}
break;
case 'BMW':
ddl2.options.length = 0;
for (i = 0; i < BMW.length; i++) {
createOption(ddl2, BMW[i], BMW[i]);
}
break;
case 'Ford':
ddl2.options.length = 0;
for (i = 0; i < Ford.length; i++) {
createOption(ddl2, Ford[i], Ford[i]);
}
break;
default:
ddl2.options.length = 0;
break;
}

}

$('.dropdown2')function createOption(ddl, text, value) {
var opt = document.createElement('option');
opt.value = value;
opt.text = text;
ddl.options.add(opt);
}

    <select class="dropdown" id="ddl" onchange="configureDropDownLists(this,document.getElementById('ddl2'))">
<option value=""></option>
<option value="Audi">Audi</option>
<option value="BMW">BMW</option>
<option value="Ford">Ford</option>
</select>

<select id="ddl2">
</select>






jquery html css






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 at 18:56









j08691

164k20189212




164k20189212










asked Nov 21 at 13:12









Haseeb Mohammed

61




61












  • what you are communicating about is not dropdown menu. it is more or less like a tree view. like in windows explorer. except that you are not asking for a trailing line from the root.
    – vssadineni
    Nov 21 at 13:37










  • And this is not the right place for ideating. Instead work on it and if you have some code and got stuck anyone from 'SO' can help you with it.
    – vssadineni
    Nov 21 at 13:44










  • @HaseebMohammed. Would a dropdown that opened another dropdown be useful, like this: w3schools.com/bootstrap/…
    – user2796515
    Nov 21 at 14:05




















  • what you are communicating about is not dropdown menu. it is more or less like a tree view. like in windows explorer. except that you are not asking for a trailing line from the root.
    – vssadineni
    Nov 21 at 13:37










  • And this is not the right place for ideating. Instead work on it and if you have some code and got stuck anyone from 'SO' can help you with it.
    – vssadineni
    Nov 21 at 13:44










  • @HaseebMohammed. Would a dropdown that opened another dropdown be useful, like this: w3schools.com/bootstrap/…
    – user2796515
    Nov 21 at 14:05


















what you are communicating about is not dropdown menu. it is more or less like a tree view. like in windows explorer. except that you are not asking for a trailing line from the root.
– vssadineni
Nov 21 at 13:37




what you are communicating about is not dropdown menu. it is more or less like a tree view. like in windows explorer. except that you are not asking for a trailing line from the root.
– vssadineni
Nov 21 at 13:37












And this is not the right place for ideating. Instead work on it and if you have some code and got stuck anyone from 'SO' can help you with it.
– vssadineni
Nov 21 at 13:44




And this is not the right place for ideating. Instead work on it and if you have some code and got stuck anyone from 'SO' can help you with it.
– vssadineni
Nov 21 at 13:44












@HaseebMohammed. Would a dropdown that opened another dropdown be useful, like this: w3schools.com/bootstrap/…
– user2796515
Nov 21 at 14:05






@HaseebMohammed. Would a dropdown that opened another dropdown be useful, like this: w3schools.com/bootstrap/…
– user2796515
Nov 21 at 14:05



















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53412837%2fhow-to-create-a-drill-down-search-menu-on-a-website%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53412837%2fhow-to-create-a-drill-down-search-menu-on-a-website%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Sphinx de Gizeh

Dijon

Guerrita