i am working in a code igniter .. i am making five rows ..actually i am doing is that the options which are display in the 2nd select box based on the first select box .. if i dont make five rows with the loop then script is working fine but if i put them in a loop ..selection dont work .. in firebug its give me response false and saying that
localhost/......./controller/get_items/undefined...
i dont know whats wrong in that code
<?php
for ($i = 0; $i < 5; $i++) {
?>
<?php echo form_dropdown('cat_id', $records2, '#', "id='category_".$i."'");?>
<?php echo form_dropdown('item_id', $records3, '#', "id='items_".$i."'"); ?>
<script type="text/javascript">
// <![CDATA[
$(document).ready(function()
{
for (var i= 0; i<5; i++)
{
$('#category_'+ i).change(function()
{
$('#items_'+ i > option").remove();
var category_id = $('#category_'+ i).val();
$.ajax({
type : "POST",
url : "stockInController/get_Items/"+category_id,
success : function(items)
{
$.each(items,function(item_id,item_name)
{
var opt = $('<option />');
opt.val(item_id);
opt.text(item_name);
$('#items_'+ i).append(opt);
});
}
});
});
}
}