One solution here is to convert the model parameters to JSON data, and then dynamically load the list when make is changed. Here is the script .
<br>Make:<br> <select id="make" name="make" required> <option value="default">Select make...</option> <option class="alfaRomeo" value="alfaRomeo">Alfa Romeo</option> <option class="abarth" value="abarth">Abarth</option> <option class="astonMartin" value="astonMartin">Aston Martin</option> <option class="audi" value="audi">Audi</option> <option class="arrinera" value="arrinera">Arrinera</option> <option class="acura" value="acura">Acura</option> <option class="ford" value="ford">Ford</option> </select><br> <br>Model:<br> <select id="model" name="model" required> <option value="default">Select Model...</option> </select><br>
And the script:
var models = [ { "make": "alfaRomeo", "value": "4cSpider", "text": "4C Spider" }, { "make": "alfaRomeo", "value": "4c", "text": "4C" }, { "make": "alfaRomeo", "value": "giulQuad", "text": "Giulietta Quadrifoglio Verde" }, { "make": "alfaRomeo", "value": "giulietta", "text": "Giulietta" }, { "make": "alfaRomeo", "value": "mitoQuad", "text": "MiTo Quadrifoglio" }, { "make": "alfaRomeo", "value": "mito", "text": "MiTo" }, { "make": "ford", "value": "focus", "text": "Focus" }, { "make": "ford", "value": "f350", "text": "F-350" } ]; $('#make').change(function () { var select = $("#model"); var make = $(this).val();
source share