İşte size ne yapmak istediğinizi bir fikir vermelidir bazı kod:
HTML
<select id="state" name="state">
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
</select>
<select id="city" name="city">
<option value="">Please select a state...</option>
</select>
PHP
<?php
$cities = array(
'IL' => array( 'Chicago', 'Naperville', 'Decatur', 'Saint Charles' ),
'IN' => array( 'Gary', 'Miller', 'Portage', 'Merrillville' )
);
print json_encode( $cities[ $_POST[ 'state' ] ] );
exit;
?>
jQuery
jQuery(document).ready(function() {
jQuery('#state').change(function() {
jQuery.post(
'some-url.php',
{
'state':jQuery('#state').val()
},
function(data, textStatus) {
jQuery.each(data, function(index, value) {
jQuery('#city').append('<option value="' + value + '">' + value + '</option>');
});
},
'json'
);
});
});