动态加载下拉框的基础知识

I'm new to php/ajax and to an extent sql. I'm trying to add a dynamic drop down box which when select will either load up another drop down box with dates or another text box. Can someone point me towards some simple examples that are not very confusing. I understand that ajax is best for this.

script

  function showfield(name){
 if(name=='byreturn')document.getElementById('div1').style.display="block";
 else document.getElementById('div1').style.display="none";
 }

if(name=='forwardorder')document.getElementById('div2').style.display="block";
else document.getElementById('div2').style.display="none";
}


  function hidefield() {
document.getElementById('div1').style.display='none';
}

page

       <tr><td> <body onload='hidefield()'>
                Choose Delivery Type </td>
               <td> <select name = 'elementtype1'id='elementtype1' onchange='showfield(this.options[this.selectedIndex].value)'>
                        <option value='forwardorder'>Forward Order</option>
                        <option value='byreturn'>By Return</option>
                        </select></td>
                        <td>

                        <div id='div1'>Enter By Return Date<input type='text''name='whatever1' />
                        </div>

                        <div id='div2'>
                        <td>Capacity</td>
                        <td><select name='deliveryDate'>
                        $listCapacityDates = $cid->ListCapacity();
                        foreach($listCapacityDates as $x) {
                        <option value='" . $x[cap] . "'</option>;
                        </div>
                        </td></tr>

This is very simple

<select name="first" onChange="populateNextBox(this)">
 <options value="1">Microsoft</options>
 <options value="2">Oracle</options>
</select>

<div id="populate"></div>

When user select the value from the drop down

required java script function

 function populateNextBox(e) {
      alert(e.value); //will print the selected value
      //used jquery for populating data
      $.post('ajax/test.php?id='+e.value, function(data) {
          $('#populate').html(data);
      });
    }

//Your ajax/test.php will create the content for the dropdown