[eluser]Unknown[/eluser]
i have a form in my view page .....as i want to send data through jquery or ajax because i dont want to reload or refresh the page . i am sending data through jquery serialize.. but all the fields are not submitting through serialize.. here first dropdown which is "supplier" is going empty .. means jquery serialize is not capturing his value //..
Code:
<?php echo form_open('stockInController/addStockIn', $attributes);
?>
<!-- Supplier -->
Select a Supplier
<select name="sup_id" id="sup_id" class='cho'>
<option id="y" value="0">--Select--</option>
<?php foreach($records1 as $r) { ?>
<option value="<?=$r->sup_id?>">
<?=$r->sup_name?>
</option>
<?php } ?>
</select>
<!-- end of Supplier -->
Date:<?php echo form_input($date); ?>
Bill No: <?php echo form_input($bill_no); ?>
<table>
<tr>
<th>Category:</th>
<th>Items:</th>
<th>Selling Price:</th>
<th>quantity:</th>
<th>total:</th>
</tr>
<?php for ($i = 0; $i < 5; $i++) {
?>
<tr>
<td><?php echo form_dropdown('cat_id'.$i, $records2, '#', "id='category_".$i."' onchange='getItems(this.value,".$i.")' ");?>
</td>
<td> <?php echo form_dropdown('item_id'.$i, $records3, '$var', "id='items_".$i."'"); ?>
</td>
<td> <input type="text" name = "price_<?php echo $i ?>" id = "price_<?php echo $i ?>" echo "$i"?>)'>
</td>
<td> <input type="text" name = "quantity_<?php echo $i ?>" id = "quantity_<?php echo $i ?>" echo "$i"?>)'>
</td>
<td> <input type="text" name = "total_<?php echo $i ?>" class = "input-small input-square" id = "total_<?php echo $i ?>">
</td>
</tr>
<?php }?>
<tr><td>
<br>
<?php echo form_button($button); ?>
<?php form_close();?>
</td></tr>
here is my jquery function ..
Code:
$('#btn').click(function(event) {
form = $("#form").serialize();
$.ajax({
type: "POST",
url: "<?php echo site_url('stockInController/addStockIn'); ?
data: form,
success: function(data){
$(".success").fadeIn(500).delay(2000).fadeOut(500);
$("#form")[0].reset();
}
});
event.preventDefault();
return false;
});