I have a drop down box which has two values, when either is chose a seperate text box or another drop down box is opened. However it part works with the second option but not the first one. can someone have a look:
php/html code:
<tr><td>
Choose Delivery Type </td>
<td> <select name = 'elementtype1'id='elementtype1'
onchange='showfield(this.options[this.selectedIndex].value)'>
<option value='Select'>Select</option>
<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) {
$content .= "<option value='".$x['month']."'>".$x['month']."</option>";
}
$content .= "</div>
</td></tr>
Ajax Code:
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";
}