I think I can use this method but don't know what to do, I have 2 drop down boxes one is gadget and one is brand, for example if my gadget drop down is empty, then my brand drop down should be empty as well, if I select computer in the gadget drop down, the brand should should drop down should generate a brand of computer brand (example: acer, asus, hp,) then if I pick cellphones it should generate other brand, example (LG, Samsung, Xiaomi, Huawei) something like that, the brand is in a database table and also the gadget also have a database table. Sorry about my English, not my primary language
Asked
Active
Viewed 45 times
-1
-
3StackOverflow is **not** a code-writing service. Add your code and tell us where the issue is. – rpm192 Dec 14 '18 at 18:03
-
Here is a tutorial for your reference. Try some code, when you get stuck then ask questions. https://www.codexworld.com/dynamic-dependent-select-box-using-jquery-ajax-php/ – Nawed Khan Dec 14 '18 at 18:07
-
https://stackoverflow.com/questions/16924082/dynamic-drop-down-box/16924652#16924652 – cssyphus Dec 14 '18 at 18:52
-
Possible duplicate of [Populate second select list based on first select list value](https://stackoverflow.com/questions/38728496/populate-second-select-list-based-on-first-select-list-value) (even though that question had an unrelated error in it) – Stephen P Dec 14 '18 at 20:08
2 Answers
0
You can achieve this, using javascript. Here's an example:
Javascript
var gadgetList = ['Cellphone', 'Tablet', 'Kindle'];
select = document.getElementById('gadgets');
for(gadget in gadgetList) {
select.add(new Option(gadgetList[gadget]));
};
HTML
<select id="gadgets"></select>

yaKay
- 115
- 13
0
Take a look at this Repl. It loads data from JSON for two dropdown combos. Gadgets and Devices, Devices is loaded dependant on Gadgets.

Bibberty
- 4,670
- 2
- 8
- 23