<form action="" method="post" id="step_form" enctype="multipart/form-data">
	<input type="hidden" name="pid" value="<?php echo $pid;?>" />
	
    <div class="form-group">
    	<label>Image</label>
        <input class="form-control" name="gall_img" type="file" />
    </div>
	
    <button type="submit" class="btn btn-primary">Add</button>
</form>
<form action="" id="step_form" method="post">
<table class="table table-bordered table-condensed">
	<thead><tr><th>Image</th><th>Action</th></tr></thead>
    <tbody>
    	<?php $i=1;foreach($galls as $faq){?>
        <tr>
        <td width="100px"><img width="100px" class="img img-responsive" src="<?php echo base_url().'assets/images/products/'.$faq->pg_img;?>" /></td>
        <td><a href="#" id="<?php echo $faq->pg_id;?>" class="btn btn-sm btn-danger coact_delete"><i class="fa fa-trash"></i></a></td></tr>
        <?php $i++;}?>
        
    </tbody>	
</table>
<!--<button type="submit" class="btn btn-primary btn-md">Sort</button>-->
</form>
<script>
$(".step_update").keyup(function(){
	var step_id=$(this).attr("id");
	var step_sno=$(this).val();
	$.ajax({
		 type: "POST",
		 url: '<?php echo base_url();?>teacher/step_sort',
		 data: {step_id:step_id,step_sno:step_sno},
		 success: function(res){
			 //alert(res);
			//$(".view_details_div").html(res);
		 }
	}); 
});



$("#step_form").submit(function(e){e.preventDefault();
	$.ajax({
			url: '<?php echo base_url();?>admin/ajax_gallery_form_submit', // Url to which the request is send
			type: "POST",             // Type of request to be send, called as method
			data: new FormData(this), // Data sent to server, a set of key/value pairs (i.e. form fields and values)
			contentType: false,       // The content type used when sending data to the server.
			cache: false,             // To unable request pages to be cached
			processData:false,        // To send DOMDocument or non processed data file it is set to false
			success: function(data)   // A function to be called if request succeeds
			{
				alert(res);
			}
		});
	
});
$(".coact_delete").click(function(e){e.preventDefault();
	if(!confirm("Sure you want to delete?")){
		  return false;
		}
	var id=$(this).attr("id");$(this).closest("tr").remove();
	$.ajax({
		 type: "POST",
		 url: '<?php echo base_url();?>teacher/gallery_delete',
		 data: {id:id},
		 success: function(response){
			 //alert(response);
		 }
	});
});
</script>