Loading a Drop Down List Using jQuery

To load a drop down list (or a simple list) from a database, there are different ways. One is to embed PHP code in the HTML code, that loops through the rows in the database and adds <option>` ` tags. <select name='mylist' id='mylist' size='1'> <?php while($rec = mysql_fetch_assoc($result)) { echo "<option>".$rec['name']."</option>"; } ?> </select> A better alternative is to dynamically load the list using Ajax. There are several advantages: In the earlier method, the generated HTML page can become too big making it too long to load the page.

Continue Reading →