February 04 2015

Jquery simple dynamic dropdown options with PHP array

Tagged Under : ,

jquery
Dynamic dropdown options always use in our Application. It can be based on user first selection to return a new listing to second dropdown options by AJAX.

Below is the example PHP array script:
$option = array();
$option[] = array('name' => 'fruits', 'value' => 'f');
$option[] = array('name' => 'vegetables', 'value' => 'v');
$option[] = array('name' => 'pizza', 'value' => 'p');

And now we need the Jquery script to build the dropdown select. Below script are allow to reuse again when you need to replace the dropdown option again.