Brad's Blog

Published: 2009-07-14

A for AJAX - OR - Dynamically generating options for a select element.

Javascript Prototype ajax web

I don't do a lot of AJAXy web development, but when I do, I usually make use of Prototype. I've recently created a form containing a <select> element whose <option>s are dynamically generated via an AJAX request. The problem however, is that a selected option was already in the form. So before the AJAX request, my HTML looked something like this:<select name="s" id="s"><option value="val1">Value 1</option><option value="val2" selected="selected">Value 2</option><option value="val3">Value ...

Published: 2008-11-24

A simple Django example with Ajax

Javascript ajax django

I often employ Ajax in HTML forms in order to update the list of options in select elements. For example, suppose a form consists of two select elements, and the options in the second depends on the values selected in the first. A simple example of this might be an Automobile Rental website that lets you choose the type of vehicle as well as the color. Not all vehicles come in the same color, though, so you might have a ...