drop-down list

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> </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 →

Handling select box (drop-down list) in a PHP form

This tutorial will show you how to add select boxes and multi-select boxes to a form, how to retrieve the input data from them, how to validate the data, and how to take different actions depending on the input. Select box Let’s look at a new input: a “select” box, also known as a “drop-down” or “pull-down” box. A select box contains one or more “options”. Each option has a “value”, just like other inputs, and also a string of text between the option tags.

Continue Reading →