I had only a small set of drop-down options that I needed to display, so I decided to be lazy and not go along the Ajax route, but rather used the original example provided on the blog (its prototype). This will slow down the page rendering if you have a lot of drop-down options that I donβt have.
The way this worked for me was that I replaced the array:
modelstxt[1] = "1\tEscort\n2\tTaurus"; modelstxt[2] = "1\tAltima\n2\tMaxima";
With template tags that will create the same array when building the page (note that I use locations and areas, not models, and does):
areastxt[0] = "0\t--"; {% for location in locations %} areastxt[{{location.id}}] = "0\t-- {% for area in areas %} {% if area.location_id == location.id %} \n{{area.id}}\t{{area.name}} {% endif %} {% endfor %}"; {% endfor %}
Disclaimer: I am noob'ish, so I can commit noob faux-pas using this approach.
source share