I created a cascading drop-down in Codeigniter, but the second drop-down is not populating in IE 9 and IE 8. Here's the relevant controller:
public function buildDropEquipment($class)
// This builds the dropdown field for newly added equipment
{
//set selected class id from POST
$class = $this->input->post('class',TRUE);
error_log("class variable: ".$class."
", 3, "/Applications/MAMP/logs/php_error.log");
//run the query for the cities we specified earlier
$this->load->model('admin/MEquipment');
$equipmentData['equipmentDrop']=$this->MEquipment->getEquipmentByClass($class);
$output = null;
foreach ($equipmentData['equipmentDrop']->result() as $row)
{
//here we build a dropdown item line for each query result
$output .= "<option value='".$row->type."'>".$row->type."</option>";
}
echo $output;
}
Here's the relevant bit from my view:
<script type="text/javascript">
$(document).ready(function() {
$("#class").change(function(){
/*dropdown post */
$.ajax({
url:"<?php echo base_url(); ?>index.php?/admin/buildDropEquipment",
data: {class: $(this).val()},
type: "POST",
success: function(data){
$("#type").html(data);
}
});
});
});
</script>
</head>
<body>
<!--machine class dropdown-->
<?php $classDrop = array('none' => 'Select One') + $classDrop; ?>
<dl>
<dt><strong><?php echo form_label('Equipment Class', 'class');?></strong></dt>
<dd>
<?php echo form_dropdown('class', $classDrop,'','class="required" id="class"'); ?>
</dd>
</dl>
<!--equipment type dropdown-->
<dl>
<dt><strong><?php echo form_label('Equipment Type', 'type');?></strong></dt>
<dd>
<select name="type" id="type">
<option value="">Select Equipment Class Above</option>
</select>
</dd>
</dl>
Can anyone tell me why it might not be working correctly in IE 9 and 8?