<div class="row">
	<div class="form-group col-md-6">
    <label>All Mini</label>
    <input type="number" class="allmini form-control" />
    </div>
	<div class="form-group col-md-6">
    <label>All Mega</label>
    <input type="number" class="allmega form-control" />
    </div>
</div>
<form action="" method="post" id="trade_form">
<input type="hidden" name="uid" value="<?php echo $uid;?>" />
<label for="checkAll"><input type="checkbox" id="checkAll"> Check All</label>
<table class="table table-condensed table-striped table-bordered">
	<thead><tr><th>Metal</th><th>Brokerage</th></tr></thead>
    <tbody>
    	<?php foreach($trades as $trade){?>
    	<tr><td>
          <?php $chk=$this->db->get_where("user_assets",array("uid"=>$uid,"asset_type"=>$trade->metal));
				if($chk->num_rows()>0){$tr=$chk->row();$brok=$tr->asset_brok;$check="checked";}else{$brok=0;$check='';}?>
        	<label><input <?php echo $check;?> type="checkbox" name="metals[]" value="<?php echo $trade->metal;?>" /> <?php echo $trade->metal;?></label></td>
        	<td width="100px"><input type="number" class="form-control <?php if($trade->met_type=="MINI"){echo "MINI";}else{echo "MEGA";}?>" value="<?php echo $brok;?>" name="<?php echo $trade->metal;?>_brok" /></td></tr>
		<?php }?>
    </tbody>
</table>
<button type="submit" class="btn btn-warning btn-block">Update</button>	
</form>
<script>
$(".allmini").keyup(function(){
	var v=$(this).val();
	$(".MINI").val(v);
});
$(".allmega").keyup(function(){
	var v=$(this).val();
	$(".MEGA").val(v);
});
$("#trade_form").submit(function(e){e.preventDefault();
	var formdata=$(this).serialize();
	$.ajax({
		 type: "POST",
		 url: '<?php echo base_url();?>swadmin/trade_form_submit',
		 data: {formdata:formdata},
		 success: function(res){
			 alert(res);
			//$(".trades_list_div").html(res);
		 }
	});
});
$("#checkAll").click(function(){
	$('input:checkbox').prop('checked', this.checked); 
});
</script>